package com.eorchis.module.classuser.ui.controller;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.apache.commons.fileupload.FileItem;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.alibaba.fastjson.JSON;
import com.eorchis.components.attachment.service.IAttachmentService;
import com.eorchis.components.attachment.ui.commond.AttachmentCommond;
import com.eorchis.constants.DeptConstants;
import com.eorchis.constants.RoleConstants;
import com.eorchis.core.page.commond.JSONObject;
import com.eorchis.core.service.IBaseService;
import com.eorchis.core.servicetemplate.treetemplate.jsonbean.JsonTreeBean;
import com.eorchis.core.springext.mvc.SessionConstant;
import com.eorchis.core.ui.commond.ResultState;
import com.eorchis.core.ui.commond.converter.IQueryCommondAttributeConverter;
import com.eorchis.core.ui.controller.AbstractBaseController;
import com.eorchis.module.basedata.domain.BaseData;
import com.eorchis.module.basedata.service.cache.BaseDataCacheUtil;
import com.eorchis.module.classplanapply.service.IClassPlanApplyService;
import com.eorchis.module.classplanapply.ui.commond.ClassPlanApplyQueryCommond;
import com.eorchis.module.classplanapply.ui.commond.ClassPlanApplyValidCommond;
import com.eorchis.module.classuser.dao.IClassUserDao;
import com.eorchis.module.classuser.domain.ClassUser;
import com.eorchis.module.classuser.domain.ClassUserCommond;
import com.eorchis.module.classuser.domain.ClassUserExport;
import com.eorchis.module.classuser.domain.ClassUserSheet;
import com.eorchis.module.classuser.domain.DepartmentUserBean;
import com.eorchis.module.classuser.domain.ExportClassUserBean;
import com.eorchis.module.classuser.domain.ExportUserBean;
import com.eorchis.module.classuser.domain.QueryClassUserBean;
import com.eorchis.module.classuser.domain.RecordInfo;
import com.eorchis.module.classuser.domain.ResultInfo;
import com.eorchis.module.classuser.domain.UserClassTypeHour;
import com.eorchis.module.classuser.domain.UserExport;
import com.eorchis.module.classuser.domain.UserInfo;
import com.eorchis.module.classuser.domain.UserSheet;
import com.eorchis.module.classuser.domain.UserStudyRecordExport;
import com.eorchis.module.classuser.service.IClassUserService;
import com.eorchis.module.classuser.ui.commond.ClassUserQueryCommond;
import com.eorchis.module.classuser.ui.commond.ClassUserValidCommond;
import com.eorchis.module.department.domain.Department;
import com.eorchis.module.department.domain.DepartmentTreeCondition;
import com.eorchis.module.department.domain.DepartmentUser;
import com.eorchis.module.department.domain.DepartmentUserCondition;
import com.eorchis.module.department.service.IDepartmentTreeService;
import com.eorchis.module.department.service.IDepartmentUserService;
import com.eorchis.module.department.ui.commond.DepartmentTreeCommond;
import com.eorchis.module.exceluitls.ReadExcelUtils;
import com.eorchis.module.remind.domain.Remind;
import com.eorchis.module.remind.service.IRemindService;
import com.eorchis.module.security.cas.domain.Role;
import com.eorchis.module.systemparameter.service.ISystemParameterService;
import com.eorchis.module.trainingclass.domain.ClassSignUpDepartment;
import com.eorchis.module.trainingclass.domain.ExportClassBean;
import com.eorchis.module.trainingclass.domain.TrainingClass;
import com.eorchis.module.trainingclass.querybean.TrainingClassQueryBean;
import com.eorchis.module.trainingclass.service.ITrainingClassService;
import com.eorchis.module.trainingclass.ui.commond.TrainingClassQueryCommond;
import com.eorchis.module.trainingclass.ui.commond.TrainingClassValidCommond;
import com.eorchis.module.trainingquestionnaire.dao.IUserAnswerLinkDao;
import com.eorchis.module.user.domain.User;
import com.eorchis.module.util.IPUtil;
import com.eorchis.module.util.StringUtils;
import com.eorchis.module.util.UnitConvertUtil;
import com.eorchis.utils.BeanUtils;
import com.eorchis.utils.DateUtil;
import com.eorchis.utils.excelutil.ExcelIO;
import com.eorchis.utils.excelutil.ExcelIOFactory;
import com.eorchis.utils.excelutil.export.bo.Sheet;
import com.eorchis.utils.utils.PropertyUtil;

/**
 * Title: ClassUserController<br>
 * Description: 培训班用户关系管理控制器<br>
 * Company: GoldGov<br>
 * Copyright @ 2012 GoldGov .All rights reserved.<br>
 * 
 * @createDate 2013-12-10
 * @version $Revision$
 */
@SuppressWarnings({ "unused", "deprecation" })
@Controller("classUserController")
@RequestMapping(value = ClassUserController.MODULE_PATH)
public class ClassUserController extends AbstractBaseController<ClassUserValidCommond, ClassUserQueryCommond> {
	// 模块页面根路径
	public static final String MODULE_PATH = "/module/classuser";

	// 组织部变量
	public static final String DEPT_TREEPATH_ZYZZB = "-1/1/7386/7466/";

	// 培训班用户关系接口
	@Resource(name = "com.eorchis.module.classuser.service.impl.ClassUserServiceImpl")
	private IClassUserService classUserService;

	@Autowired
	@Qualifier("attachmentService")
	private IAttachmentService attachmentService;

	// 数据字典缓存
	@Resource(name = "com.eorchis.module.basedata.service.cache.BaseDataCacheUtil")
	private BaseDataCacheUtil baseDataCacheUtil;

	// 提醒表接口
	@Resource(name = "com.eorchis.module.remind.service.impl.RemindServiceImpl")
	private IRemindService remindService;

	@Autowired
	@Qualifier("com.eorchis.module.department.service.impl.DepartmentTreeServiceImpl")
	private IDepartmentTreeService departmentTreeService;

	// 培训班信息接口
	@Autowired
	@Qualifier("com.eorchis.module.trainingclass.service.impl.TrainingClassServiceImpl")
	private ITrainingClassService trainingClassService;

	@Resource(name = "com.eorchis.module.classuser.dao.impl.ClassUserDaoImpl")
	private IClassUserDao classUserDao;

	// 班级计划报名接口
	@Autowired
	@Qualifier("com.eorchis.module.classplanapply.service.impl.ClassPlanApplyServiceImpl")
	private IClassPlanApplyService classPlanApplyService;

	@Autowired
	@Qualifier("com.eorchis.module.trainingquestionnaire.dao.impl.UserAnswerLinkDaoImpl")
	private IUserAnswerLinkDao userAnswerLinkDao;

	@Autowired
	private ReadExcelUtils excelUtils;

	@Override
	public IBaseService getService() {
		return classUserService;
	}

	@Override
	public String getModulePath() {
		return MODULE_PATH;
	}

	@Autowired
	@Qualifier("attributeConverter")
	private ArrayList<IQueryCommondAttributeConverter> attributeConverter;

	@Autowired
	@Qualifier("com.eorchis.module.department.service.impl.DepartmentUserServiceImpl")
	private IDepartmentUserService iDepartmentUserService;

	@Resource(name = "com.eorchis.module.systemparameter.service.impl.SystemParameterServiceImpl")
	private ISystemParameterService systemParameterService;

	/**
	 * 统计--干部培训档案查询(别的逻辑不用调用此方法)
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author Max
	 * @date 2014-01-08
	 */
	@RequestMapping(value = "/findUserStudyRecordList")
	public @ResponseBody JSONObject findUserStudyRecordList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response) throws Exception {

		// 执行查询逻辑
		// queryCommond.setSearchUserID("20141540");
		// 查询培训班的培训信息和人员线上学时信息
		List<RecordInfo> list = classUserService.findUserStudyRecordList(queryCommond);
		// 查询人员信息

		DepartmentUserCondition condition = new DepartmentUserCondition();
		condition.setSearchUserId(queryCommond.getSearchUserID());
		DepartmentUser userInfo = iDepartmentUserService.getDepartmentUser(condition);
		// 封装人员信息

		UserInfo ui = constructionUserInfo(userInfo);

		// 返回对象
		ResultInfo rinfo = new ResultInfo();
		rinfo.setTrainingSituation(list);
		rinfo.setUserInfo(ui);

		JSONObject j = new JSONObject();
		j.setData(rinfo);
		return j;
	}

	/**
	 * 查询某年度学习档案
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author HuangTF
	 * @date 2014-03-26
	 */
	@RequestMapping(value = "/findStudyRecordByYear")
	public String findStudyRecordByYear(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, Model model, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (!PropertyUtil.objectNotEmpty(queryCommond.getTrainingClassYear())) {
			queryCommond.setTrainingClassYear(DateUtil.getDateString(new Date(), "yyyy"));
		}
		if (!PropertyUtil.objectNotEmpty(queryCommond.getSearchUserID())) {
			queryCommond.setSearchUserID(((User) request.getSession().getAttribute(SessionConstant.USER_INFO)).getUserId());
		}
		// 查询培训班的培训信息和人员线上学时信息
		RecordInfo classRecordInfo = classUserService.findStudyRecordByYear(queryCommond);

		model.addAttribute("classRecordInfo", classRecordInfo);

		return "forward:../../portal/project/classuser/classRecordInfo.jsp";
	}

	/**
	 * 查询当前年度学习档案
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author HuangTF
	 * @date 2014-03-26
	 */
	@RequestMapping(value = "/findStudyRecordByYearToJson")
	public String findStudyRecordByYearToJson(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (!PropertyUtil.objectNotEmpty(queryCommond.getTrainingClassYear())) {
			queryCommond.setTrainingClassYear(DateUtil.getDateString(new Date(), "yyyy"));
		}
		if (!PropertyUtil.objectNotEmpty(queryCommond.getSearchUserID())) {
			queryCommond.setSearchUserID(((User) request.getSession().getAttribute(SessionConstant.USER_INFO)).getUserId());
		}
		// 查询培训班的培训信息和人员线上学时信息
		RecordInfo classRecordInfo = classUserService.findStudyRecordByYear(queryCommond);
		List<RecordInfo> list = new ArrayList<RecordInfo>();
		list.add(classRecordInfo);

		queryCommond.setResultList(list);
		return "";
	}

	/**
	 * 构造人员信息
	 * 
	 * @param userInfo
	 * @return
	 * @author Max
	 * @date 2013-1-8
	 */
	private UserInfo constructionUserInfo(DepartmentUser userInfo) {
		UserInfo ui = new UserInfo();
		// 姓名
		ui.setUserName(userInfo.getUser().getUserName());
		// 性别
		// if(PropertyUtil.objectNotEmpty(userInfo.getUser().getSexCode()))
		// {
		// ui.setUserSex(userInfo.getUser().getSexCode().getDataName());
		// }else{
		// ui.setUserSex("");
		// }
		// //政治面貌
		// if(PropertyUtil.objectNotEmpty(userInfo.getUser().getPoliticesCode()))
		// {
		// ui.setPoliticalLandscape(userInfo.getUser().getPoliticesCode().getDataName());
		// }else{
		// ui.setPoliticalLandscape("");
		// }
		// 文化程度 学历
		// if(PropertyUtil.objectNotEmpty(userInfo.getUser().getDegreeCode()))
		// {
		// ui.setEducation(userInfo.getUser().getDegreeCode().getDataName());
		// }else{
		// ui.setEducation("");
		// }
		// 生日
		if (PropertyUtil.objectNotEmpty(userInfo.getUser().getBirthday())) {
			ui.setBirthday(new SimpleDateFormat("yyyy-MM-dd").format(userInfo.getUser().getBirthday()));
		} else {
			ui.setBirthday("");
		}
		// 单位
		if (PropertyUtil.objectNotEmpty(userInfo.getDepartment())) {
			ui.setDeptName(userInfo.getDepartment().getDeptName());
		} else {
			ui.setDeptName("");
		}
		// 职务
		if (PropertyUtil.objectNotEmpty(userInfo.getUser().getDutyRemark())) {
			ui.setPosition(userInfo.getUser().getDutyRemark());
		} else {
			ui.setPosition("");
		}
		// 职级
		// if(PropertyUtil.objectNotEmpty(userInfo.getUser().getDutyLevelCode()))
		// {
		// ui.setRankName(userInfo.getUser().getDutyLevelCode().getDataName());
		// }else{
		// ui.setRankName("");
		// }
		// 任职时间
		if (PropertyUtil.objectNotEmpty(userInfo.getUser().getOfficeHoldingDate())) {
			ui.setWorkingTime(new SimpleDateFormat("yyyy-MM-dd").format(userInfo.getUser().getOfficeHoldingDate()));
		}

		// 添加身份证号 by Max at 2014-04-12
		ui.setPaperNum(userInfo.getUser().getPaperNum());

		return ui;
	}

	/**
	 * 查询当前培训班的学员
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author HuangTF
	 * @createDate 2013-12-11
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/findListUser")
	public String findListUser(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		// 如果是单位上报市级项目查询班级人员,只查询当前管理范围内的人员
		TrainingClassValidCommond trainingClass = trainingClassService.find(queryCommond.getSearchClassID());
		com.eorchis.module.security.cas.domain.Department department = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		queryCommond.setSearchDepId(department.getDeptID());
		List<QueryClassUserBean> resultList = (List<QueryClassUserBean>) classUserService.findList(queryCommond);
		queryCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		resultState.setMessage("查询成功");
		return "";
	}
	
	/**
	 * 查询当前培训班的学员
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author RongSL
	 * 2017年10月25日
	 */
	@RequestMapping(value = "/findListUserCount")
	public String findListUserCount(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond,HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		Integer userCount=Integer.valueOf(request.getParameter("userCount"));
		Integer preCount=Integer.valueOf(request.getParameter("preCount"));
		Integer classUserCount=Integer.valueOf(classUserService.findListUserCount(queryCommond).toString());
		Integer Surplus=userCount-classUserCount;
		if(preCount>Surplus){
			if(classUserCount>userCount)
				resultState.setMessage("本班限报"+userCount+"人，目前已报"+userCount+"人，可报0人。");
			else
				resultState.setMessage("本班限报"+userCount+"人，目前已报"+classUserCount+"人，可报"+(Surplus<0?0:Surplus)+"人。");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}else{
			resultState.setMessage("可以报名");
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		}
		return "";
	}

	/**
	 * 查询管理范围下培训班已报学员列表(委托部委办班在线报名系统)
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2014-1-7
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/findSelectedUserList")
	public String findSelectedUserList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		String roleCode = currentRole.getCode();

		if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource())) {
			if (!ClassUserQueryCommond.CLICK_SOURCE.equals(queryCommond.getClickSource().toString())) {
				Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
				queryCommond.setSearchDepId(d.getDeptID());
			} else {
				queryCommond.setSearchDepId(null);
			}
		}

		// if (RoleConstants.ROLE_CODE_BW_ADMIN.equals(roleCode)) {// 部委管理员
		// com.eorchis.module.security.cas.domain.Department d =
		// (com.eorchis.module.security.cas.domain.Department)
		// request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		// queryCommond.setSearchDepId(d.getDeptID());
		// // queryCommond.setSearchMinistrieID("7498");
		// } else if (RoleConstants.ROLE_CODE_DW_ADMIN.equals(roleCode)) {//
		// 单位管理员
		// com.eorchis.module.security.cas.domain.Department d =
		// (com.eorchis.module.security.cas.domain.Department)
		// request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		// queryCommond.setSearchDepId(d.getDeptID());
		// // queryCommond.setSearchDepId("7449");
		// }
		List<QueryClassUserBean> resultList = (List<QueryClassUserBean>) classUserService.findList(queryCommond);
		queryCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		resultState.setMessage("查询成功");
		return "";
	}

	/**
	 * 查看培训班报名-审核通过人员
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/findSelectedUserPassList")
	public String findSelectedUserPassList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		String roleCode = currentRole.getCode();
		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		queryCommond.setSearchDepId(d.getDeptID());
		List<QueryClassUserBean> resultList = (List<QueryClassUserBean>) classUserService.findList(queryCommond);
		queryCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		resultState.setMessage("查询成功");
		return "";
	}

	/**
	 * 查询管理范围下培训班已报学员列表(委托部委办班在线报名系统)
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2014-1-7
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/findSelectedUserList2")
	public String findSelectedUserList2(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		String roleCode = currentRole.getCode();
		if (RoleConstants.ROLE_CODE_BW_ADMIN.equals(roleCode)) {// 部委管理员
			com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			queryCommond.setSearchMinistrieID(d.getDeptID());
			// queryCommond.setSearchMinistrieID("7498");
		} else if (RoleConstants.ROLE_CODE_DW_ADMIN.equals(roleCode)) {// 单位管理员
			com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			queryCommond.setSearchDepId(d.getDeptID());
			// queryCommond.setSearchDepId("7449");
		}
		List<QueryClassUserBean> resultList = (List<QueryClassUserBean>) classUserService.findList(queryCommond);
		queryCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		resultState.setMessage("查询成功");
		return "";
	}

	/**
	 * 区级项目管理，查询培训班已报学员列表，查询全部审核通过的，与管理范围无关
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author HuangTF
	 * @createDate 2014-5-5
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/findAllAuditingUserList")
	public String findAllAuditingUserList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		Role role = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		if (role.getRoleCode().equals(TrainingClass.TRAINING_SECOND_ADMIN)) {
			com.eorchis.module.security.cas.domain.Department department = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			queryCommond.setSearchDepId(department.getDeptID());
		}
		queryCommond.setAuditingState(1);// 审核通过
		List<QueryClassUserBean> resultList = (List<QueryClassUserBean>) classUserService.findList(queryCommond);
		queryCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		resultState.setMessage("查询成功");
		return "";
	}

	/**
	 * 更新用户培训学时
	 * 
	 * @param commond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author HuangTF
	 * @createDate 2013-12-11
	 */
	@RequestMapping(value = "/updateTrainingHours")
	public String updateTrainingHours(@ModelAttribute("result") ClassUserValidCommond commond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		String mess = classUserService.updateTrainingHours(commond);
		resultState.setMessage(mess);
		return "";
	}

	/**
	 * 查询未选人员列表(委托部委办班在线报名系统)
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2013-12-10
	 */
	@RequestMapping(value = "/findNoSelectedUserList")
	public String findNoSelectedUserList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, Model model, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		com.eorchis.module.security.cas.domain.Department department = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		queryCommond.setSearchDepId(department.getDeptID());
		// queryCommond.setSearchDepId("7449");
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态为失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID()) && PropertyUtil.objectNotEmpty(queryCommond.getSearchDepId())) {
			List<QueryClassUserBean> queryClassUserBeans = classUserService.findNoSelectedUserList(queryCommond);
			queryCommond.setResultList(queryClassUserBeans);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功");
		}
		return "";
	}

	/**
	 * 查询报名页左侧树(委托部委办班在线报名系统)
	 * 
	 * @param commond
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2013-12-10
	 */
	@RequestMapping(value = "/findDepartmentTree")
	public @ResponseBody List<JsonTreeBean> findDepartmentTree(DepartmentTreeCommond commond, HttpServletRequest request) throws Exception {
		List<JsonTreeBean> result = new ArrayList<JsonTreeBean>();
		// 取出当前管理范围
		if (!PropertyUtil.objectNotEmpty(commond.getNode()) || commond.getNode().equals(JsonTreeBean.ROOT_NODE_PARENT_ID)) {
			com.eorchis.module.security.cas.domain.Department department = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			commond.setNode(department.getDeptID());
			// commond.setNode("1822419");
			DepartmentTreeCondition condition = new DepartmentTreeCondition();
			BeanUtils.copyProperties(commond, condition);
			condition.setFindLeapNode(true);
			List<JsonTreeBean> list = departmentTreeService.doProcess(condition);
			JsonTreeBean rootBean = new JsonTreeBean();
			rootBean.setText(department.getDeptName());
			// rootBean.setText("房山区");
			rootBean.setLeaf(false);
			rootBean.setId(department.getDeptID());
			// rootBean.setId("1822419");
			rootBean.setChildren(list);
			rootBean.setState("close");
			rootBean.setExpandable(true);
			result.add(rootBean);
		} else {
			DepartmentTreeCondition condition = new DepartmentTreeCondition();
			BeanUtils.copyProperties(commond, condition);
			condition.setFindLeapNode(true);
			result = departmentTreeService.doProcess(condition);
		}
		return result;
	}

	/**
	 * 删除学员（撤销报名）(委托部委办班在线报名系统)
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author HuangTF
	 * @createDate 2013-12-11
	 */
	@RequestMapping(value = "/deleteUserById")
	public String deleteUserById(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassUserIds()) && queryCommond.getSearchClassUserIds().length > 0) {
			// 单位上报区级项目,当没有结班时删除报名人员需要修改上报状态 结班：1未结班：2
			// if (queryCommond.getOpenState() == 1) {
			// ClassUserQueryCommond cq = new ClassUserQueryCommond();
			// cq.setSearchClassUserIds(queryCommond.getSearchClassUserIds());
			// List<?> list = classUserService.findClassInfo(cq);

			// String roleCode = ((Role)
			// request.getSession().getAttribute(SessionConstant.CURRENT_ROLE)).getCode();
			// if (RoleConstants.ROLE_CODE_GJC_ADMIN.equals(roleCode) ||
			// RoleConstants.ROLE_CODE_ONE_ADMIN.equals(roleCode)) {//
			// 干教处管理员或一级管理员
			// classUserService.delete(queryCommond.getSearchClassUserIds());
			// //
			// classUserService.toVoidUserByUserId(queryCommond.getSearchUserIds());
			// userAnswerLinkDao.delUserAnswerLink(queryCommond.getSearchUserIds());
			// } else if (RoleConstants.ROLE_CODE_TWO_ADMIN.equals(roleCode))
			// {// 二级管理员
			// classUserService.deleteUserForDW(queryCommond);
			// }

			// 当操作来源为报名审核时默认通过，否则默认待审核
			if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource()) && queryCommond.getClickSource().equals(ClassUser.SOURCE_AUDIT_ONE)) {
				classUserService.saveAnnulUser(queryCommond.getSearchUserIds());
				classUserService.delete(queryCommond.getSearchClassUserIds());
				// classUserService.toVoidUserByUserId(queryCommond.getSearchUserIds());
				userAnswerLinkDao.delUserAnswerLink(queryCommond.getSearchUserIds());
			} else if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource()) && queryCommond.getClickSource().equals(ClassUser.SOURCE_AUDIT_TWO)) {
				classUserService.saveAnnulUser(queryCommond.getSearchUserIds());
				classUserService.deleteUserForDW(queryCommond);
			} else {
				resultState.setState(ResultState.RESULT_STATE_FAIL);
				resultState.setMessage("当前操作来源不正确！");
			}
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("操作成功");
			/*
			 * } else { resultState.setMessage("已结班或未开班"); }
			 */

			/**
			 * 添加提醒
			 * 
			 * @Date 2016-05-12
			 * @author RongSL
			 * @Params 提醒类型，培训班名称，承办部委名称，提醒分类
			 */
			// try {
			// Department dep = (Department)
			// request.getSession().getAttribute("currentScope");
			// Object[] o = null;
			// for (Object obj : list) {
			// o = (Object[]) obj;
			// if (RoleConstants.ROLE_CODE_BW_ADMIN.equals(roleCode)) {
			// remindService.remindOperate(Remind.BMSH, (String) o[0],
			// dep.getDeptCode(), RoleConstants.ROLE_BW_NAME, (String) o[1],
			// (String) o[2], (String) o[3], "同意", "撤销报名申请",
			// (String) o[4], Remind.PXB);
			// } else if (RoleConstants.ROLE_CODE_DW_ADMIN.equals(roleCode)) {
			// remindService.remindOperate(Remind.CXBMSQ, (String) o[0],
			// dep.getDeptCode(), RoleConstants.ROLE_DF_NAME, (String) o[1],
			// (String) o[2], (String) o[3], "撤销", "报名",
			// (String) o[4], Remind.PXB);
			// }
			// }
			// } catch (Exception e) {
			// System.out.println("报名审核提醒接口出错了！");
			// }

		} else {
			resultState.setMessage("未选中任何人员");
		}
		return "";
	}

	/**
	 * 批量添加人员到培训班
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author YanDong
	 * @createDate 2016-1-6
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/batchSave")
	public String batchSave(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态为失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchUserIds())) {
			// 根据userid查询出单位id
			List<DepartmentUserBean> userDeplist = this.trainingClassService.getDepIdByUserIds(queryCommond.getSearchUserIds());
			// 返回每个单位下这次要报多少名
			Map<String, Integer> map = groupDepUserNum(userDeplist);

			ClassPlanApplyQueryCommond applyCommond = new ClassPlanApplyQueryCommond();
			ClassUserQueryCommond classUserQueryCommond = new ClassUserQueryCommond();
			applyCommond.setSearchClassId(queryCommond.getSearchClassID());
			classUserQueryCommond.setSearchClassID(queryCommond.getSearchClassID());
			Boolean isTrue = true;
			for (String key : map.keySet()) {
				// 查询这个部门在这个班下面的调整人数
				applyCommond.setSearchDeptId(key);
				List<ClassPlanApplyValidCommond> apply = (List<ClassPlanApplyValidCommond>) classPlanApplyService.findAllList(applyCommond);
				if (PropertyUtil.objectNotEmpty(apply)) {
					// 查询这个部门在这个班下的已报名人数
					classUserQueryCommond.setSearchDepId(key);
					Long classUserCount = this.classUserService.count(classUserQueryCommond);
					if ((map.get(key) + classUserCount.intValue()) > apply.get(0).getAsignCount()) {
						isTrue = false;
					}
				} else {
					isTrue = false;
					resultState.setMessage("此班级暂无名额");
				}
			}
			if (isTrue) {
				queryCommond.setAuditingState(ClassUser.IS_AUDITING_Y);
				String msg = classUserService.batchSaveClassUser(queryCommond);
				if ("添加成功".equals(msg)) {
					resultState.setState(ResultState.RESULT_STATE_SUCCESS);
					resultState.setMessage(msg);
				} else {
					resultState.setMessage(msg);
				}
			} else {
				if (!PropertyUtil.objectNotEmpty(resultState.getMessage())) {
					resultState.setMessage("此班级名额已满，请联系管理员");
				}
			}
		} else {
			resultState.setMessage("未选中任何人员");
		}
		return "";
	}

	private Map<String, Integer> groupDepUserNum(List<DepartmentUserBean> userDeplist) {
		Map<String, Integer> map = new HashMap<String, Integer>();
		for (DepartmentUserBean departmentUserBean : userDeplist) {
			if (map.containsKey(departmentUserBean.getDepId())) {
				map.put(departmentUserBean.getDepId(), map.get(departmentUserBean.getDepId()) + 1);
			} else {
				map.put(departmentUserBean.getDepId(), 1);
			}
		}
		return map;
	}

	/**
	 * 批量添加人员到培训班(区级项目报名)
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2013-12-25
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/batchSaveUser")
	public String batchSaveUser(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态为失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchUserIds()) && PropertyUtil.objectNotEmpty(queryCommond.getSearchApplyOrganCode())) {
			com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			queryCommond.setSearchDepId(d.getDeptID());
			// queryCommond.setSearchDepId("1822175");
			// 判断是否在报名时间之间，在此之间是报名，过了报名截止时间是补报名
			TrainingClassQueryCommond com = new TrainingClassQueryCommond();
			com.setSearchClassId(queryCommond.getSearchClassID());
			List<TrainingClassValidCommond> trainingClass = (List<TrainingClassValidCommond>) trainingClassService.findList(com);
			TrainingClass tc = trainingClass.get(0).getTrainingClass();
			Date beginTime = tc.getEnterBeginTime();
			Date endTime = tc.getEnterEndTime();
			Date nowDate = new Date();
			java.util.Calendar c1 = java.util.Calendar.getInstance();
			java.util.Calendar c2 = java.util.Calendar.getInstance();
			java.util.Calendar c3 = java.util.Calendar.getInstance();
			c1.setTime(beginTime);
			c2.setTime(endTime);
			c3.setTime(nowDate);
			int result1 = c1.compareTo(c3);
			int result2 = c2.compareTo(c3);
			if (result1 < 0 && result2 > 0) {// 报名
				String msg = classUserService.batchSaveUser(queryCommond);
				if ("添加成功".equals(msg)) {
					resultState.setState(ResultState.RESULT_STATE_SUCCESS);
					resultState.setMessage(msg);
				} else {
					resultState.setMessage(msg);
				}
			}
			if (result2 < 0) {// 报名截止（补报名）
				String msg = classUserService.replenishBatchSaveUser(queryCommond);
				resultState.setState(ResultState.RESULT_STATE_SUCCESS);
				resultState.setMessage(msg);
			}
			if (result1 > 0) {// 未到报名时间
				resultState.setMessage("未到报名时间，不可以报名");
			}
		} else {
			resultState.setMessage("未选中任何人员");
		}
		return "";
	}

	/**
	 * 填写学时的时候添加人员到培训班
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author HuangTF
	 * @createDate 2013-12-20
	 */
	@RequestMapping(value = "/addUser")
	public String addUser(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchUserIds())) {
			classUserService.addUser(queryCommond);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("添加成功");
		} else {
			resultState.setState(ResultState.RESULT_STATE_FAIL);
			resultState.setMessage("未选中任何人员");
		}
		return "";
	}

	/**
	 * 用于排序的方法
	 * 
	 * @param queryCommond
	 * @param request
	 * @param attributeConverter
	 */
	@SuppressWarnings("unchecked")
	private void parameterValueConver(ClassUserQueryCommond queryCommond, HttpServletRequest request, List<IQueryCommondAttributeConverter> attributeConverter) {
		for (IQueryCommondAttributeConverter queryCommondAttributeConverter : attributeConverter) {
			queryCommondAttributeConverter.convert(queryCommond, request.getParameterMap());
		}
	}

	/**
	 * 再次报名(委托部委办班在线报名系统)
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2013-12-23
	 */
	@RequestMapping(value = "/updateAuditingState")
	public String updateAuditingState(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassUserIds()) && queryCommond.getSearchClassUserIds().length > 0) {
			// 单位上报区级项目,当没有结班时再次报名人员需要修改上报状态 结班：1未结班：2
			if (queryCommond.getOpenState() == 1) {
				classUserService.updateAuditingState(queryCommond);
				resultState.setState(ResultState.RESULT_STATE_SUCCESS);
				resultState.setMessage("再次报名成功");
			} else {
				resultState.setMessage("已结班或未开班");
			}

		} else {
			resultState.setMessage("未选中任何人员");
		}
		return "";
	}

	/**
	 * 查询当前管理范围下人员列表
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2014-1-8
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/findUserList")
	public String findUserList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, Model model, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态为失败
		List<QueryClassUserBean> queryClassUserBeans;
		if (PropertyUtil.objectNotEmpty(request.getSession().getAttribute("signUpUsers"))) {
			queryClassUserBeans = (List<QueryClassUserBean>) request.getSession().getAttribute("signUpUsers");
			request.getSession().removeAttribute("signUpUsers");
		} else {
			Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
			Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN) || queryCommond.getSearchDepId().equals(DeptConstants.DEPT_ROOT_ID))
				queryCommond.setIsSuperBusinessAdmin(true);
			// 判断当前操作人是否为所在班级的主办单位，如果是主办单位切查询条件仅为学员账号查询时则级联查询报名单位下的学员
			if (!(PropertyUtil.objectNotEmpty(queryCommond.getSearchUserName()) || PropertyUtil.objectNotEmpty(queryCommond.getDutyRemark()) || PropertyUtil.objectNotEmpty(queryCommond.getRank()))) {
				TrainingClass tc = classUserDao.find(TrainingClass.class, queryCommond.getSearchClassID());
				if (tc.getSponsorID().equals(d.getDeptID()) && PropertyUtil.objectNotEmpty(queryCommond.getSearchLoginID()) && tc.getSignUpDepartment().size() > 0) {
					// String depIds[]=new String[]{" (ud.treepath like
					// '"+d.getTreepath()+"%' or"};
					String depIds[] = new String[] { " (instr(ud.treepath,'" + d.getTreepath() + "')=1 or" };
					for (ClassSignUpDepartment t : tc.getSignUpDepartment()) {
						// depIds[0]+=" ud.treepath like
						// '"+t.getDept().getTreepath()+"%' or";
						depIds[0] += " instr(ud.treepath,'" + t.getDept().getTreepath() + "')=1 or";
					}
					depIds[0] = depIds[0].substring(0, depIds[0].length() - 2) + ")";
					queryCommond.setSearchTreePaths(depIds);
				}
			}
			if (!PropertyUtil.objectNotEmpty(queryCommond.getSearchDepId())) {
				queryCommond.setSearchDepId(d.getDeptID());
			}
			queryClassUserBeans = classUserService.findNoSelectedUserList(queryCommond);
		}
		queryCommond.setResultList(queryClassUserBeans);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		resultState.setMessage("查询成功");
		return "";
	}

	/**
	 * 导出Excel当前管理范围下人员列表
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2014-1-9
	 */
	@RequestMapping(value = "/exportUserListExcel")
	public void exportUserListExcel(Model model, HttpServletRequest request, ClassUserQueryCommond queryCommond, HttpServletResponse response) throws Exception {
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchDepId())) {
			if (PropertyUtil.objectNotEmpty(queryCommond.getSearchUserName())) {
				String str = new String(queryCommond.getSearchUserName().getBytes("iso-8859-1"), "utf-8");
				queryCommond.setSearchUserName(str);
			}
			if (PropertyUtil.objectNotEmpty(queryCommond.getSearchDepName())) {
				String str = new String(queryCommond.getSearchDepName().getBytes("iso-8859-1"), "utf-8");
				queryCommond.setSearchDepName(str);
			}
			// 查询结果
			queryCommond.setPage(-1);// 不分页
			List<QueryClassUserBean> queryClassUserBeans = new ArrayList<QueryClassUserBean>();
			if (PropertyUtil.objectNotEmpty(queryCommond.getBeforeDutyYear()) || PropertyUtil.objectNotEmpty(queryCommond.getEndDateStatistics())) {
				queryClassUserBeans = classUserService.findUserInfoHoursStudyRecordList(queryCommond);
			} else {
				// queryClassUserBeans=classUserService.findNoSelectedUserList(queryCommond);
				// 更改为查询当前单位所有人员，包括在当前单位任职的人员 By HuangTF At 2014-06-11
				queryClassUserBeans = classUserService.findAllUserListByDepId(queryCommond);
			}
			List<ExportUserBean> userList = new ArrayList<ExportUserBean>();
			for (QueryClassUserBean qcub : queryClassUserBeans) {
				ExportUserBean eub = new ExportUserBean();
				BeanUtils.copyProperties(qcub, eub);
				userList.add(eub);
			}
			// 设置并导出人员列表
			UserExport userExport = new UserExport();
			userExport.setExportUserBeanList(userList);
			UserSheet userSheet = new UserSheet();
			userSheet.setExportObject(userExport);
			userSheet.setExprotFormatName("userListExportConfig");
			userSheet.setSheetName("学员列表");

			Sheet[] sheetArray = new Sheet[] { userSheet };// 导出Excel的Sheet集合
			ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
			String title = "学员列表";
			response.setContentType("application/msexcel;charset=ISO8859-1");
			response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
			OutputStream out = response.getOutputStream();
			excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
		}
	}

	/**
	 * 统计--干部培训档案导出Excel(别的逻辑不用调用此方法)
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @date 2014-01-10
	 */
	@RequestMapping(value = "/exportUserStudyRecordListExcel")
	public String exportUserStudyRecordListExcel(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response) throws Exception {
		// 查询培训班的培训信息和人员线上学时信息
		List<RecordInfo> list = classUserService.findUserStudyRecordList(queryCommond);
		// 查询人员信息
		DepartmentUserCondition condition = new DepartmentUserCondition();
		condition.setSearchUserId(queryCommond.getSearchUserID());
		DepartmentUser userInfo = iDepartmentUserService.getDepartmentUser(condition);
		// 封装人员信息
		UserInfo ui = constructionUserInfo(userInfo);
		/*
		 * // 设置并导出人员列表 UserStudyRecordExport rinfo=new UserStudyRecordExport();
		 * rinfo.setTrainingSituation(list); rinfo.setUserInfo(ui); UserSheet
		 * userSheet = new UserSheet(); userSheet.setExportObject(rinfo);
		 * userSheet.setExprotFormatName("userStudyRecordListExportConfig");
		 * userSheet.setSheetName("处级干部培训情况统计表");
		 * 
		 * Sheet[] sheetArray = new Sheet[] { userSheet };// 导出Excel的Sheet集合
		 * ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具 String
		 * title="处级干部培训情况统计表";
		 * response.setContentType("application/msexcel;charset=ISO8859-1");
		 * response.setHeader("Content-disposition", "attachment; filename=" +
		 * java.net.URLEncoder.encode(title, "UTF-8") + ".xls"); OutputStream
		 * out = response.getOutputStream(); excelio.exportExcel(out,
		 * "resumeExportStyle", sheetArray, false);
		 */
		UserStudyRecordExport rinfo = new UserStudyRecordExport();
		rinfo.setTrainingSituation(list);
		rinfo.setUserInfo(ui);
		List<UserStudyRecordExport> r = new ArrayList<UserStudyRecordExport>();
		r.add(rinfo);
		queryCommond.setResultList(r);
		return "forward:/portal/project/classuser/exportUserStudyRecordList.jsp";
	}

	/**
	 * 培训班学员报名情况列表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2015-1-4
	 */
	@RequestMapping(value = "/getSelectedUserList")
	public String getSelectedUserList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 调用service层查询此班级中的学员
			Role role = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
			com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			if (PropertyUtil.objectNotEmpty(d.getDeptID()) && role.getRoleCode().equals("department_admin"))
				queryCommond.setSearchDepId(d.getDeptID());
			// 如果是单位管理员 则查询管理范围下的人员
			/*
			 * if(queryCommond.getType()!=null&&queryCommond.getType().equals(
			 * "dept" )) { com.eorchis.module.security.cas.domain.Department
			 * department=
			 * (com.eorchis.module.security.cas.domain.Department)request
			 * .getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			 * queryCommond.setSearchDepId(department.getDeptID()); }
			 */
			List<QueryClassUserBean> resultList = classUserService.getSelectedUserList(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setMessage("未选中任何班级！");
		}
		return "";
	}

	/**
	 * 培训班学员报名情况列表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2015-1-4
	 */
	@RequestMapping(value = "/getSelectedUserListAttedence")
	public String getSelectedUserListAttedence(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 调用service层查询此班级中的学员

			// 如果是单位管理员 则查询管理范围下的人员
			if (queryCommond.getType() != null && queryCommond.getType().equals("dept")) {
				com.eorchis.module.security.cas.domain.Department department = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
				queryCommond.setSearchDepId(department.getDeptID());
			}
			List<QueryClassUserBean> resultList = classUserService.getSelectedUserListAttedence(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setMessage("未选中任何班级！");
		}
		return "";
	}

	/**
	 * 培训班单位报名情况列表（复用）
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2015-1-4
	 */
	@RequestMapping(value = "/getSelectedDepartmentList")
	public String getSelectedDepartmentList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 调用service层查询此班级中的学员
			List<QueryClassUserBean> resultList = classUserService.getSelectedDepartmentList(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setMessage("未选中任何班级！");
		}
		return "";
	}

	/**
	 * 培训班单位人员报名情况列表
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author Xupp
	 * @createDate 2015-1-8
	 */
	@RequestMapping(value = "/getSelectedDepartmentUserList")
	public String getSelectedDepartmentUserList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchDepId())) {
			// 调用service层查询此班级中的学员
			List<QueryClassUserBean> resultList = classUserService.getSelectedDepartmentUserList(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setMessage("未选中任何班级！");
		}
		return "";
	}

	/**
	 * 撤销报名
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author Xupp
	 * @createDate 2015-1-4
	 */
	@RequestMapping(value = "/deleteSelectedUser")
	public String deleteSelectedUser(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		int count = classUserService.deleteSelectedUser(queryCommond);
		if (count <= 0) {
			resultState.setState(ResultState.RESULT_STATE_FAIL);
			resultState.setMessage("系统错误，请联系管理员！");
		}
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		resultState.setMessage("撤销成功！");
		return "";
	}

	/**
	 * 查詢班級考勤情況
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月11日
	 */
	@RequestMapping(value = "/getClassAttendancerList")
	public String getClassAttendancerList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {

		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			List<QueryClassUserBean> resultList = classUserService.getClassAttendancerList(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setMessage("未选中任何班级！");
		}
		return "";

	}

	/**
	 * 修改考勤
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月11日
	 */
	@RequestMapping(value = "/updateAttendanceState")
	public String updateAttendanceState(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassUserIds()) && queryCommond.getSearchClassUserIds().length > 0) {
			classUserService.updateAttendanceState(queryCommond);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("修改考勤成功");
		} else {
			resultState.setMessage("未选中任何人员");
		}
		return "";
	}

	/**
	 * 修改考勤状态
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月11日
	 */
	@RequestMapping(value = "/updateAttendanceStateByClassIdUser")
	public String updateAttendanceStateByClassId(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID()) && PropertyUtil.objectNotEmpty(queryCommond.getAttendanceState()) && PropertyUtil.objectNotEmpty(queryCommond.getSearchClassUserId())) {
			classUserService.updateAttendanceStateByClassId(queryCommond);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("修改考勤成功");
		} else {
			resultState.setMessage("未选中任何人员");
		}
		return "";
	}

	/**
	 * 修改考勤状态
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月11日
	 */
	@RequestMapping(value = "/updateAttendanceStateByClassIdAll")
	public String updateAttendanceStateByClassIdAll(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			classUserService.updateAttendanceStateByClassIdAll(queryCommond);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("修改考勤成功");
		} else {
			resultState.setMessage("未选中任何人员");
		}
		return "";
	}

	/**
	 * 单位报名列表（管理范围）
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2015-1-12
	 */
	@RequestMapping(value = "/getSelectedUserListByDeptId")
	public String getSelectedUserListByDeptId(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		// 获得登陆者的管理范围
		com.eorchis.module.security.cas.domain.Department department = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		if (PropertyUtil.objectNotEmpty(department) && PropertyUtil.objectNotEmpty(department.getDeptID())) {
			// 判断传入参数
			if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
				queryCommond.setSearchDepId(department.getDeptID());
				// 调用service层查询此班级中的学员
				List<QueryClassUserBean> resultList = classUserService.getSelectedUserList(queryCommond);
				queryCommond.setResultList(resultList);
				resultState.setState(ResultState.RESULT_STATE_SUCCESS);
				resultState.setMessage("查询成功！");
			} else {
				resultState.setMessage("未选中任何班级！");
			}
		} else {
			resultState.setMessage("获取管理范围失败！");
		}
		return "";
	}

	/**
	 * 待选报名列表（17）
	 * 
	 * @author YanDong
	 * @date 2016-1-6
	 */
	@RequestMapping(value = "/getToChooseUserList")
	public String getToChooseUserList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		// com.eorchis.module.security.cas.domain.Department
		// department=(com.eorchis.module.security.cas.domain.Department)request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// if(!PropertyUtil.objectNotEmpty(queryCommond.getQueryType())){
			// queryCommond.setQueryType(1);
			// }
			// //从单位查询待选列表
			// if(queryCommond.getQueryType().equals(2)){
			// queryCommond.setSearchTreePath(department.getTreepath());
			// }
			List<QueryClassUserBean> resultList = classUserService.getToChooseUserList(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功");
		} else {
			resultState.setMessage("班级ID不能为空");
		}
		return "";
	}

	/**
	 * 导出学员列表for工委
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月27日
	 */
	@RequestMapping(value = "/exportClassUserListExcelForGW")
	public void exportClassUserListExcelForGW(@ModelAttribute("result") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response) throws Exception {
		qCommond.setSearchReportState(TrainingClass.IS_REPORT_Y);
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListNoPage(qCommond);
		List<String> classIdList = new ArrayList<String>();
		for (TrainingClassQueryBean bean : resultList) {
			classIdList.add(bean.getClassId());
		}
		qCommond.setSearchClassIdList(classIdList);
		List<QueryClassUserBean> beanList = classUserService.findTrainingClassUserListNoPage(qCommond);
		// 判断是否存在中央组织部的treePath
		/*
		 * if(PropertyUtil.objectNotEmpty(beanList)&&beanList.size()>0){ for(int
		 * i =0;i<beanList.size();i++){
		 * if(PropertyUtil.objectNotEmpty(beanList.get
		 * (i))&&PropertyUtil.objectNotEmpty(beanList.get(i).getTreePath())){
		 * if(beanList.get(i).getTreePath().indexOf(DEPT_TREEPATH_ZYZZB)!=-1){
		 * beanList.get(i).setDepName("中央组织部"); } } } }
		 */

		List<ExportClassUserBean> exrbeanList = new ArrayList<ExportClassUserBean>();
		if (PropertyUtil.objectNotEmpty(beanList) && beanList.size() > 0) {
			for (QueryClassUserBean classUserbean : beanList) {
				if (PropertyUtil.objectNotEmpty(classUserbean.getTreePath())) {
					if (classUserbean.getTreePath().indexOf(DEPT_TREEPATH_ZYZZB) != -1) {
						classUserbean.setDepName("中央组织部");
					}
				}
				ExportClassUserBean extBean = new ExportClassUserBean();
				org.springframework.beans.BeanUtils.copyProperties(classUserbean, extBean);
				exrbeanList.add(extBean);
			}
		}
		ClassUserExport classUserExport = new ClassUserExport();
		classUserExport.setExpClassUserBeanList(exrbeanList);
		ClassUserSheet classUserSheet = new ClassUserSheet();
		classUserSheet.setExportObject(classUserExport);
		classUserSheet.setExprotFormatName("classUserListExportConfig");
		classUserSheet.setSheetName("班级学员名单");

		Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "班级学员名单";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 导出学员列表for中组部
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月27日
	 */
	@RequestMapping(value = "/exportClassUserListExcelForZZB")
	public void exportClassUserListExcelForZZB(@ModelAttribute("result") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response) throws Exception {
		qCommond.setSearchReportState(TrainingClass.IS_REPORT_Y);
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListNoPage(qCommond);
		List<String> classIdList = new ArrayList<String>();
		for (TrainingClassQueryBean bean : resultList) {
			classIdList.add(bean.getClassId());
		}
		qCommond.setSearchClassIdList(classIdList);
		List<QueryClassUserBean> beanList = classUserService.findTrainingClassUserListNoPage(qCommond);

		List<ExportClassUserBean> exrbeanList = new ArrayList<ExportClassUserBean>();
		if (PropertyUtil.objectNotEmpty(beanList) && beanList.size() > 0) {

			for (QueryClassUserBean classUserbean : beanList) {
				if (PropertyUtil.objectNotEmpty(classUserbean.getTreePath())) {
					if (classUserbean.getTreePath().indexOf(DEPT_TREEPATH_ZYZZB) != -1) {
						classUserbean.setDepName("中央组织部");
					}
				}
				ExportClassUserBean extBean = new ExportClassUserBean();
				org.springframework.beans.BeanUtils.copyProperties(classUserbean, extBean);
				exrbeanList.add(extBean);
			}
		}
		ClassUserExport classUserExport = new ClassUserExport();
		classUserExport.setExpClassUserBeanList(exrbeanList);
		ClassUserSheet classUserSheet = new ClassUserSheet();
		classUserSheet.setExportObject(classUserExport);
		classUserSheet.setExprotFormatName("classUserListExportConfig");
		classUserSheet.setSheetName("班级学员名单");

		Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "班级学员名单";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 导出学员列表for单位
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月27日
	 */
	@RequestMapping(value = "/exportClassUserListExcelForDW")
	public void exportClassUserListExcelForDW(@ModelAttribute("result") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response) throws Exception {
		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		if (PropertyUtil.objectNotEmpty(d) && PropertyUtil.objectNotEmpty(d.getDeptID())) {
			qCommond.setSearchTrainingApplyDeptId(d.getDeptID());
			// queryCommond.setSearchTrainingApplyDeptId("8410");
			qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);// 活动班级
			qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);// 已发布班级
			qCommond.setAuditState(TrainingClass.IS_AUDIT_Y);// 审核通过班级
			// 执行查询逻辑
			List<TrainingClassQueryBean> resultList = trainingClassService.findTrainingClassListByDeptNoPage(qCommond);
			List<String> classIdList = new ArrayList<String>();
			for (TrainingClassQueryBean bean : resultList) {
				classIdList.add(bean.getClassId());
			}
			qCommond.setSearchClassIdList(classIdList);
			// 添加 treepath by Max at 2015-02-17
			qCommond.setSearchTrainingApplyDeptTreepath(d.getTreepath());
			List<QueryClassUserBean> beanList = classUserService.findTrainingClassUserListNoPage(qCommond);
			List<ExportClassUserBean> exrbeanList = new ArrayList<ExportClassUserBean>();
			for (QueryClassUserBean classUserbean : beanList) {
				ExportClassUserBean extBean = new ExportClassUserBean();
				org.springframework.beans.BeanUtils.copyProperties(classUserbean, extBean);
				exrbeanList.add(extBean);
			}
			ClassUserExport classUserExport = new ClassUserExport();
			classUserExport.setExpClassUserBeanList(exrbeanList);
			ClassUserSheet classUserSheet = new ClassUserSheet();
			classUserSheet.setExportObject(classUserExport);
			classUserSheet.setExprotFormatName("classUserListExportConfig");
			classUserSheet.setSheetName("班级学员名单");

			Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
			ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
			String title = "班级学员名单";
			response.setContentType("application/msexcel;charset=ISO8859-1");
			response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
			OutputStream out = response.getOutputStream();
			excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
		}
	}

	/**
	 * 导出学员列表for高校
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月27日
	 */
	@RequestMapping(value = "/exportClassUserListExcelForGX")
	public void exportClassUserListExcelForGX(@ModelAttribute("result") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response) throws Exception {

		List<String> classIdList = new ArrayList<String>();
		classIdList.add(qCommond.getSearchClassId());
		qCommond.setSearchClassIdList(classIdList);
		List<QueryClassUserBean> beanList = classUserService.findTrainingClassUserListNoPage(qCommond);
		List<ExportClassUserBean> exrbeanList = new ArrayList<ExportClassUserBean>();
		if (PropertyUtil.objectNotEmpty(beanList) && beanList.size() > 0) {
			for (QueryClassUserBean classUserbean : beanList) {
				if (PropertyUtil.objectNotEmpty(classUserbean.getTreePath())) {
					if (classUserbean.getTreePath().indexOf(DEPT_TREEPATH_ZYZZB) != -1) {
						classUserbean.setDepName("中央组织部");
					}
				}
				ExportClassUserBean extBean = new ExportClassUserBean();
				org.springframework.beans.BeanUtils.copyProperties(classUserbean, extBean);
				exrbeanList.add(extBean);
			}
		}
		ClassUserExport classUserExport = new ClassUserExport();
		classUserExport.setExpClassUserBeanList(exrbeanList);
		ClassUserSheet classUserSheet = new ClassUserSheet();
		classUserSheet.setExportObject(classUserExport);
		classUserSheet.setExprotFormatName("classUserListExportConfig");
		classUserSheet.setSheetName("班级学员名单");

		Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "班级学员名单";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 导出工委班级人员考勤详细情况列表
	 * 
	 * @param commond
	 * @param bindingResult
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author LongJZ
	 * @createDate 2015-3-27
	 */
	@RequestMapping(value = "/exportClassUserDetailAttendanceListForGW")
	public void exportClassUserDetailAttendanceListForGW(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// 获取班级信息
		String classId = qCommond.getSearchClassId();
		TrainingClassValidCommond vCommond = new TrainingClassValidCommond();
		if (PropertyUtil.objectNotEmpty(classId)) {
			TrainingClassValidCommond co = trainingClassService.find(classId);
			BeanUtils.copyProperties(co, vCommond);
			// 补全班级信息
			vCommond = trainingClassService.swapClassInfo(vCommond);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} else {
			resultState.setMessage("培训班ID为空");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

		ExportClassBean eub = new ExportClassBean();
		eub.setBeginDate(sdf.format(vCommond.getBeginDate()));
		eub.setClassName(vCommond.getClassName());
		if (vCommond.getClassUserNum() == -1) {
			eub.setClassUserNum("不限");
		} else {
			eub.setClassUserNum(vCommond.getClassUserNum().toString());
		}
		if (vCommond.getReportedNum() <= 0)
			eub.setAttendanceRate("0.00%");
		else {
			/*
			 * eub.setAttendanceRate((new BigDecimal(
			 * (vCommond.getAttendanceNum().doubleValue() /
			 * vCommond.getReportedNum().doubleValue() * 100) ).setScale(2,
			 * BigDecimal.ROUND_HALF_UP)).toString() + "%");
			 */
			// 修改出勤率（全勤+未全勤）/报名人数 2015/5/6 -GUOL
			eub.setAttendanceRate(double2precent(((double) vCommond.getAttendanceNum() + (double) vCommond.getAbsenceNum()) / (double) vCommond.getReportedNum()));
		}
		eub.setAttendanceNum(vCommond.getAttendanceNum().longValue());
		eub.setAbsenceNum(vCommond.getAbsenceNum().longValue());
		eub.setLeaveNum(vCommond.getLeaveNum().longValue());
		eub.setNoAttendanceNum(vCommond.getNoAttendanceNum().longValue());
		eub.setClassNum(vCommond.getClassNum());
		eub.setEndDate(sdf.format(vCommond.getEndDate()));
		eub.setReportedNum(vCommond.getReportedNum().longValue());
		eub.setTrainingHour(vCommond.getTrainingHour());
		eub.setTrainingDeptName(vCommond.getTrainingDeptName());

		// 获取班级人员信息
		qCommond.setSearchReportState(TrainingClass.IS_REPORT_Y);
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListNoPage(qCommond);
		List<String> classIdList = new ArrayList<String>();
		for (TrainingClassQueryBean bean : resultList) {
			classIdList.add(bean.getClassId());
		}
		qCommond.setSearchClassIdList(classIdList);
		// 考勤查询人员列表的排序不同，故加参数处理 by Max at 2015-04-07
		qCommond.setSearchType("attedence");
		List<QueryClassUserBean> beanList = classUserService.findTrainingClassUserListNoPage(qCommond);

		List<ExportClassUserBean> exrbeanList = new ArrayList<ExportClassUserBean>();
		if (PropertyUtil.objectNotEmpty(beanList) && beanList.size() > 0) {
			for (QueryClassUserBean classUserbean : beanList) {
				if (PropertyUtil.objectNotEmpty(classUserbean.getTreePath())) {
					if (classUserbean.getTreePath().indexOf(DEPT_TREEPATH_ZYZZB) != -1) {
						classUserbean.setDepName("中央组织部");
					}
				}
				ExportClassUserBean extBean = new ExportClassUserBean();
				org.springframework.beans.BeanUtils.copyProperties(classUserbean, extBean);
				exrbeanList.add(extBean);
			}
		}
		ClassUserExport classUserExport = new ClassUserExport();
		classUserExport.setClassBean(eub);
		classUserExport.setExpClassUserBeanList(exrbeanList);
		ClassUserSheet classUserSheet = new ClassUserSheet();
		classUserSheet.setExportObject(classUserExport);
		classUserSheet.setExprotFormatName("attendanceDetailExportConfig");
		classUserSheet.setSheetName(vCommond.getClassName() + "考勤情况");

		Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = vCommond.getClassName() + "考勤情况";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 导出中组部班级人员考勤详细情况列表
	 * 
	 * @param commond
	 * @param bindingResult
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author LongJZ
	 * @createDate 2015-3-27
	 */
	@RequestMapping(value = "/exportClassUserDetailAttendanceListForZZB")
	public void exportClassUserDetailAttendanceListForZZB(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// 获取班级信息
		String classId = qCommond.getSearchClassId();
		TrainingClassValidCommond vCommond = new TrainingClassValidCommond();
		if (PropertyUtil.objectNotEmpty(classId)) {
			TrainingClassValidCommond co = trainingClassService.find(classId);
			BeanUtils.copyProperties(co, vCommond);
			// 补全班级信息
			vCommond = trainingClassService.swapClassInfo(vCommond);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} else {
			resultState.setMessage("培训班ID为空");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

		ExportClassBean eub = new ExportClassBean();
		eub.setBeginDate(sdf.format(vCommond.getBeginDate()));
		eub.setClassName(vCommond.getClassName());
		if (vCommond.getClassUserNum() == -1) {
			eub.setClassUserNum("不限");
		} else {
			eub.setClassUserNum(vCommond.getClassUserNum().toString());
		}
		if (vCommond.getReportedNum() <= 0)
			eub.setAttendanceRate("0.00%");
		else {
			/*
			 * eub.setAttendanceRate((new BigDecimal(
			 * (vCommond.getAttendanceNum().doubleValue() /
			 * vCommond.getReportedNum().doubleValue() * 100) ).setScale(2,
			 * BigDecimal.ROUND_HALF_UP)).toString() + "%");
			 */
			eub.setAttendanceRate(double2precent(((double) vCommond.getAttendanceNum() + (double) vCommond.getAbsenceNum()) / (double) vCommond.getReportedNum()));
		}
		eub.setAttendanceNum(vCommond.getAttendanceNum().longValue());
		eub.setAbsenceNum(vCommond.getAbsenceNum().longValue());
		eub.setLeaveNum(vCommond.getLeaveNum().longValue());
		eub.setNoAttendanceNum(vCommond.getNoAttendanceNum().longValue());
		eub.setClassNum(vCommond.getClassNum());
		eub.setEndDate(sdf.format(vCommond.getEndDate()));
		eub.setReportedNum(vCommond.getReportedNum().longValue());
		eub.setTrainingHour(vCommond.getTrainingHour());
		eub.setTrainingDeptName(vCommond.getTrainingDeptName());

		// 获取班级人员信息
		qCommond.setSearchReportState(TrainingClass.IS_REPORT_Y);
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListNoPage(qCommond);
		List<String> classIdList = new ArrayList<String>();
		for (TrainingClassQueryBean bean : resultList) {
			classIdList.add(bean.getClassId());
		}
		qCommond.setSearchClassIdList(classIdList);
		qCommond.setSearchType("attedence");
		List<QueryClassUserBean> beanList = classUserService.findTrainingClassUserListNoPage(qCommond);

		List<ExportClassUserBean> exrbeanList = new ArrayList<ExportClassUserBean>();
		if (PropertyUtil.objectNotEmpty(beanList) && beanList.size() > 0) {

			for (QueryClassUserBean classUserbean : beanList) {
				if (PropertyUtil.objectNotEmpty(classUserbean.getTreePath())) {
					if (classUserbean.getTreePath().indexOf(DEPT_TREEPATH_ZYZZB) != -1) {
						classUserbean.setDepName("中央组织部");
					}
				}
				ExportClassUserBean extBean = new ExportClassUserBean();
				org.springframework.beans.BeanUtils.copyProperties(classUserbean, extBean);
				exrbeanList.add(extBean);
			}
		}
		ClassUserExport classUserExport = new ClassUserExport();
		classUserExport.setClassBean(eub);
		classUserExport.setExpClassUserBeanList(exrbeanList);
		ClassUserSheet classUserSheet = new ClassUserSheet();
		classUserSheet.setExportObject(classUserExport);
		classUserSheet.setExprotFormatName("attendanceDetailExportConfig");
		classUserSheet.setSheetName(vCommond.getClassName() + "考勤情况");

		Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = vCommond.getClassName() + "考勤情况";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 导出单位班级人员考勤详细情况列表
	 * 
	 * @param commond
	 * @param bindingResult
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author LongJZ
	 * @createDate 2015-3-27
	 */
	@RequestMapping(value = "/exportClassUserDetailAttendanceListForDW")
	public void exportClassUserDetailAttendanceListForDW(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// 获取班级信息

		Role role = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		String classId = qCommond.getSearchClassId();
		TrainingClassValidCommond vCommond = new TrainingClassValidCommond();
		if (PropertyUtil.objectNotEmpty(classId)) {
			TrainingClassValidCommond co = trainingClassService.find(classId);
			BeanUtils.copyProperties(co, vCommond);
			vCommond.setDeptCode(role.getRoleCode());
			vCommond.setManagerDepartId(d.getDeptID());
			// 补全班级信息
			vCommond = trainingClassService.swapClassInfo(vCommond);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} else {
			resultState.setMessage("培训班ID为空");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

		ExportClassBean eub = new ExportClassBean();
		eub.setBeginDate(sdf.format(vCommond.getBeginDate()));
		eub.setClassName(vCommond.getClassName());
		if (vCommond.getClassUserNum() == -1) {
			eub.setClassUserNum("不限");
		} else {
			eub.setClassUserNum(vCommond.getClassUserNum().toString());
		}
		if (vCommond.getReportedNum() <= 0)
			eub.setAttendanceRate("0.00%");
		else {
			/*
			 * eub.setAttendanceRate((new BigDecimal(
			 * (vCommond.getAttendanceNum().doubleValue() /
			 * vCommond.getReportedNum().doubleValue() * 100) ).setScale(2,
			 * BigDecimal.ROUND_HALF_UP)).toString() + "%");
			 */
			eub.setAttendanceRate(double2precent((double) (vCommond.getAttendanceNum() + vCommond.getAbsenceNum()) / (double) vCommond.getReportedNum()));
		}
		eub.setAttendanceNum(vCommond.getAttendanceNum().longValue());
		eub.setAbsenceNum(vCommond.getAbsenceNum().longValue());
		eub.setLeaveNum(vCommond.getLeaveNum().longValue());
		eub.setNoAttendanceNum(vCommond.getNoAttendanceNum().longValue());
		eub.setClassNum(vCommond.getClassNum());
		eub.setEndDate(sdf.format(vCommond.getEndDate()));
		eub.setReportedNum(vCommond.getReportedNum().longValue());
		eub.setTrainingHour(vCommond.getTrainingHour());
		eub.setTrainingDeptName(vCommond.getTrainingDeptName());

		// 获取班级人员信息
		// com.eorchis.module.security.cas.domain.Department
		// d=(com.eorchis.module.security.cas.domain.Department)request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		if (PropertyUtil.objectNotEmpty(d) && PropertyUtil.objectNotEmpty(d.getDeptID())) {
			qCommond.setSearchTrainingApplyDeptId(d.getDeptID());
			// queryCommond.setSearchTrainingApplyDeptId("8410");
			qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);// 活动班级
			qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);// 已发布班级
			qCommond.setAuditState(TrainingClass.IS_AUDIT_Y);// 审核通过班级
			// 执行查询逻辑
			// List<TrainingClassQueryBean> resultList =
			// trainingClassService.findTrainingClassListByDeptNoPage(qCommond);
			List<String> classIdList = new ArrayList<String>();
			// for(TrainingClassQueryBean bean:resultList){
			if (PropertyUtil.objectNotEmpty(classId))
				classIdList.add(classId);
			qCommond.setSearchClassIdList(classIdList);
			// 添加 treepath by Max at 2015-02-17
			qCommond.setSearchTrainingApplyDeptTreepath(d.getTreepath());
			qCommond.setSearchType("attedence");
			List<QueryClassUserBean> beanList = classUserService.findTrainingClassUserListNoPage(qCommond);
			List<ExportClassUserBean> exrbeanList = new ArrayList<ExportClassUserBean>();
			for (QueryClassUserBean classUserbean : beanList) {
				ExportClassUserBean extBean = new ExportClassUserBean();
				org.springframework.beans.BeanUtils.copyProperties(classUserbean, extBean);
				exrbeanList.add(extBean);
			}
			ClassUserExport classUserExport = new ClassUserExport();
			classUserExport.setClassBean(eub);
			classUserExport.setExpClassUserBeanList(exrbeanList);
			ClassUserSheet classUserSheet = new ClassUserSheet();
			classUserSheet.setExportObject(classUserExport);
			classUserSheet.setExprotFormatName("attendanceDetailForDeptExportConfig");
			classUserSheet.setSheetName(vCommond.getClassName() + "考勤情况");

			Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
			ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
			String title = vCommond.getClassName() + "考勤情况";
			response.setContentType("application/msexcel;charset=ISO8859-1");
			response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
			OutputStream out = response.getOutputStream();
			excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
		}
	}

	/**
	 * 导出高校班级人员考勤详细情况列表
	 * 
	 * @param commond
	 * @param bindingResult
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author LongJZ
	 * @createDate 2015-3-27
	 */
	@RequestMapping(value = "/exportClassUserDetailAttendanceListForGX")
	public void exportClassUserDetailAttendanceListForGX(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// 获取班级信息
		String classId = qCommond.getSearchClassId();
		TrainingClassValidCommond vCommond = new TrainingClassValidCommond();
		if (PropertyUtil.objectNotEmpty(classId)) {
			TrainingClassValidCommond co = trainingClassService.find(classId);
			BeanUtils.copyProperties(co, vCommond);
			// 补全班级信息
			vCommond = trainingClassService.swapClassInfo(vCommond);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} else {
			resultState.setMessage("培训班ID为空");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

		ExportClassBean eub = new ExportClassBean();
		eub.setBeginDate(sdf.format(vCommond.getBeginDate()));
		eub.setClassName(vCommond.getClassName());
		if (vCommond.getClassUserNum() == -1) {
			eub.setClassUserNum("不限");
		} else {
			eub.setClassUserNum(vCommond.getClassUserNum().toString());
		}
		if (vCommond.getReportedNum() <= 0)
			eub.setAttendanceRate("0.00%");
		else {
			/*
			 * eub.setAttendanceRate((new BigDecimal(
			 * (vCommond.getAttendanceNum().doubleValue() /
			 * vCommond.getReportedNum().doubleValue() * 100) ).setScale(2,
			 * BigDecimal.ROUND_HALF_UP)).toString() + "%");
			 */
			eub.setAttendanceRate(double2precent((double) (vCommond.getAttendanceNum() + vCommond.getAbsenceNum()) / (double) vCommond.getReportedNum()));
		}
		eub.setAttendanceNum(vCommond.getAttendanceNum().longValue());
		eub.setAbsenceNum(vCommond.getAbsenceNum().longValue());
		eub.setLeaveNum(vCommond.getLeaveNum().longValue());
		eub.setNoAttendanceNum(vCommond.getNoAttendanceNum().longValue());
		eub.setClassNum(vCommond.getClassNum());
		eub.setEndDate(sdf.format(vCommond.getEndDate()));
		eub.setReportedNum(vCommond.getReportedNum().longValue());
		eub.setTrainingHour(vCommond.getTrainingHour());
		eub.setTrainingDeptName(vCommond.getTrainingDeptName());

		// 获取班级人员信息
		List<String> classIdList = new ArrayList<String>();
		classIdList.add(qCommond.getSearchClassId());
		qCommond.setSearchClassIdList(classIdList);
		// 考勤查询人员列表的排序不同，故加参数处理 by Max at 2015-04-07
		qCommond.setSearchType("attedence");
		List<QueryClassUserBean> beanList = classUserService.findTrainingClassUserListNoPage(qCommond);
		List<ExportClassUserBean> exrbeanList = new ArrayList<ExportClassUserBean>();
		if (PropertyUtil.objectNotEmpty(beanList) && beanList.size() > 0) {
			for (QueryClassUserBean classUserbean : beanList) {
				if (PropertyUtil.objectNotEmpty(classUserbean.getTreePath())) {
					if (classUserbean.getTreePath().indexOf(DEPT_TREEPATH_ZYZZB) != -1) {
						classUserbean.setDepName("中央组织部");
					}
				}
				/*
				 * if
				 * (PropertyUtil.objectNotEmpty(classUserbean.getAttendanceState
				 * ())) { if (classUserbean.getAttendanceState() == 1)
				 * 
				 * }
				 */
				ExportClassUserBean extBean = new ExportClassUserBean();
				org.springframework.beans.BeanUtils.copyProperties(classUserbean, extBean);
				exrbeanList.add(extBean);
			}
		}
		ClassUserExport classUserExport = new ClassUserExport();
		classUserExport.setClassBean(eub);
		classUserExport.setExpClassUserBeanList(exrbeanList);
		ClassUserSheet classUserSheet = new ClassUserSheet();
		classUserSheet.setExportObject(classUserExport);
		classUserSheet.setExprotFormatName("attendanceDetailExportConfig");
		classUserSheet.setSheetName(vCommond.getClassName() + "考勤情况");

		Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = vCommond.getClassName() + "考勤情况";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 查询班级已报名人员列表(委托部委办班在线报名系统)
	 * 
	 * @author YanDong
	 * @createDate 2016-1-6
	 */
	@RequestMapping(value = "/findClassUserListByAttendanceState")
	public String findClassUserListByAttendanceState(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 如果是单位管理员 则查询管理范围下的人员
			// Role role=(Role)
			// request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
			// com.eorchis.module.security.cas.domain.Department
			// d=(com.eorchis.module.security.cas.domain.Department)request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			// if (PropertyUtil.objectNotEmpty(d.getDeptID()) &&
			// role.getRoleCode().equals("department_admin"))
			// queryCommond.setSearchDepId(d.getDeptID());
			/*
			 * if(queryCommond.getType()!=null&&queryCommond.getType().equals(
			 * "dept" )) { com.eorchis.module.security.cas.domain.Department
			 * department=
			 * (com.eorchis.module.security.cas.domain.Department)request
			 * .getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			 * queryCommond.setSearchDepId(department.getDeptID()); }
			 */
			// 如果功能是 点击报名人数展开_已选报名列表 那么把单位id传过来。可以看下dao层
			List<QueryClassUserBean> resultList = classUserService.findClassUserListByAttendanceState(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setMessage("未选中任何班级！");
		}
		return "";
	}

	/**
	 * 查询班级已报名人员列表
	 * @author RongSL
	 * @createDate 2016-12-23
	 */
	@RequestMapping(value = "/findClassUserListNoSignUp")
	public String findClassUserListNoSignUp(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN))
			queryCommond.setIsSuperBusinessAdmin(true);
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 如果是单位管理员 则查询管理范围下的人员
			if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource())) {
				if (!ClassUserQueryCommond.CLICK_SOURCE.equals(queryCommond.getClickSource().toString())) {
					Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
					queryCommond.setSearchDepId(d.getDeptID());
				} else {
					queryCommond.setSearchDepId(null);
				}
			}
			// 如果功能是 点击报名人数展开_已选报名列表 那么把单位id传过来。可以看下dao层
			List<QueryClassUserBean> resultList = classUserService.findClassUserListNoSignUp(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setMessage("未选中任何班级！");
		}
		return "";
	}
	
	/**
	 * 导出当前管理范围下已报名的人员列表身份证号
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author RongSL
	 * 2017年12月29日
	 */
	@RequestMapping(value = "/exportUserPaperNumExcel")
	public void exportUserPaperNumExcel(Model model, HttpServletRequest request, ClassUserQueryCommond queryCommond, HttpServletResponse response) throws Exception {
			// 查询结果
			queryCommond.setLimit(9999);// 不分页
			if (attributeConverter != null) {
				parameterValueConver(queryCommond, request, attributeConverter);
			}
			Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
			if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN))
				queryCommond.setIsSuperBusinessAdmin(true);
			// 判断传入参数
			if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
				// 如果是单位管理员 则查询管理范围下的人员
				if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource())) {
					if (!ClassUserQueryCommond.CLICK_SOURCE.equals(queryCommond.getClickSource().toString())) {
						Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
						queryCommond.setSearchDepId(d.getDeptID());
					} else {
						queryCommond.setSearchDepId(null);
					}
				}
				// 如果功能是 点击报名人数展开_已选报名列表 那么把单位id传过来。可以看下dao层
				List<QueryClassUserBean> resultList = classUserService.findClassUserListNoSignUp(queryCommond);
				
				List<ExportClassUserBean> exrbeanList = new ArrayList<ExportClassUserBean>();
				if (PropertyUtil.objectNotEmpty(resultList) && resultList.size() > 0) {
					for (QueryClassUserBean classUserbean : resultList) {
						ExportClassUserBean extBean = new ExportClassUserBean();
						org.springframework.beans.BeanUtils.copyProperties(classUserbean, extBean);
						exrbeanList.add(extBean);
					}
				}
				ClassUserExport classUserExport = new ClassUserExport();
				classUserExport.setExpClassUserBeanList(exrbeanList);
				ClassUserSheet classUserSheet = new ClassUserSheet();
				classUserSheet.setExportObject(classUserExport);
				classUserSheet.setExprotFormatName("exportUserPaperNumConfig");
				classUserSheet.setSheetName("班级学员名单");

				Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
				ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
				String title = "班级学员名单";
				response.setContentType("application/msexcel;charset=ISO8859-1");
				response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
				OutputStream out = response.getOutputStream();
				excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
			}
		}
	
	/**
	 * 查询班级已报名人员列表(归档数据)
	 * @author RongSL
	 * @createDate 2016-12-23
	 */
	@RequestMapping(value = "/findClassUserListByPxarchives")
	public String findClassUserListByPxarchives(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN))
			queryCommond.setIsSuperBusinessAdmin(true);
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 如果是单位管理员 则查询管理范围下的人员
			if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource())) {
				if (!ClassUserQueryCommond.CLICK_SOURCE.equals(queryCommond.getClickSource().toString())) {
					Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
					queryCommond.setSearchDepId(d.getDeptID());
					queryCommond.setSearchTreePath(d.getTreepath());
				} else {
					queryCommond.setSearchDepId(null);
				}
			}
			// 如果功能是 点击报名人数展开_已选报名列表 那么把单位id传过来。可以看下dao层
			List<QueryClassUserBean> resultList = classUserService.findClassUserListByPxarchives(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setMessage("未选中任何班级！");
		}
		return "";
	}
	
	/**
	 * 查询班级未报名人员列表(归档数据)
	 * @author RongSL
	 * 2018年3月8日
	 */
	@RequestMapping(value = "/findNoClassUserListByPxarchives")
	public String findNoClassUserListByPxarchives(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN))
			queryCommond.setIsSuperBusinessAdmin(true);
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 如果是单位管理员 则查询管理范围下的人员
			Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			queryCommond.setSearchTreePath(d.getTreepath());
			// 如果功能是 点击报名人数展开_已选报名列表 那么把单位id传过来。可以看下dao层
			List<QueryClassUserBean> resultList = classUserService.findNoClassUserListByPxarchives(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setMessage("未选中任何班级！");
		}
		return "";
	}

	/**
	 * 查询班级考核人员列表
	 * 
	 * @author RongSL
	 * @createDate 2017-02-22
	 */
	@RequestMapping(value = "/findClassUserListExaminationList")
	public String findClassUserListExaminationList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN))
			queryCommond.setIsSuperBusinessAdmin(true);
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 如果是单位管理员 则查询管理范围下的人员
			if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource())) {
				if (!ClassUserQueryCommond.CLICK_SOURCE.equals(queryCommond.getClickSource().toString())) {
					Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
					queryCommond.setSearchDepId(d.getDeptID());
				} else {
					queryCommond.setSearchDepId(null);
				}
			}
			// 至查询报名通过人员
			Integer searchSignUpState[] = new Integer[] { 1, 5 };
			queryCommond.setSearchSignUpState(searchSignUpState);
			List<QueryClassUserBean> resultList = classUserService.findClassUserListExaminationList(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setMessage("未选中任何班级！");
		}
		return "";
	}

	/**
	 * 查询培训班报名-已报已审列表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/findClassUserSignUpExamineList")
	public String findClassUserSignUpExamineList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 如果是单位管理员 则查询管理范围下的人员
			Role role = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
			com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			if (PropertyUtil.objectNotEmpty(d.getDeptID()) && role.getRoleCode().equals("department_admin"))
				queryCommond.setSearchTreePath(d.getTreepath());
			queryCommond.setSearchDepId(d.getDeptID());
			/*
			 * if(queryCommond.getType()!=null&&queryCommond.getType().equals(
			 * "dept" )) { com.eorchis.module.security.cas.domain.Department
			 * department=
			 * (com.eorchis.module.security.cas.domain.Department)request
			 * .getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			 * queryCommond.setSearchDepId(department.getDeptID()); }
			 */
			// 如果功能是 点击报名人数展开_已选报名列表 那么把单位id传过来。可以看下dao层
			List<QueryClassUserBean> resultList = classUserService.findClassUserListNoSignUp(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setMessage("未选中任何班级！");
		}
		return "";
	}

	/**
	 * 查询班级已报名人员列表(委托部委办班在线报名系统)
	 * 
	 * @author YanDong
	 * @createDate 2016-1-6
	 */
	@RequestMapping(value = "/findClassUserListByAttendanceState2")
	public String findClassUserListByAttendanceState2(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 如果是单位管理员 则查询管理范围下的人员
			// Role role=(Role)
			// request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
			// com.eorchis.module.security.cas.domain.Department
			// d=(com.eorchis.module.security.cas.domain.Department)request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			// if (PropertyUtil.objectNotEmpty(d.getDeptID()) &&
			// role.getRoleCode().equals("department_admin"))
			// queryCommond.setSearchDepId(d.getDeptID());
			/*
			 * if(queryCommond.getType()!=null&&queryCommond.getType().equals(
			 * "dept" )) { com.eorchis.module.security.cas.domain.Department
			 * department=
			 * (com.eorchis.module.security.cas.domain.Department)request
			 * .getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			 * queryCommond.setSearchDepId(department.getDeptID()); }
			 */
			// 如果功能是 点击报名人数展开_已选报名列表 那么把单位id传过来。可以看下dao层
			List<QueryClassUserBean> resultList = classUserService.findClassUserListByAttendanceState2(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setMessage("未选中任何班级！");
		}
		return "";
	}

	/**
	 * 查询班级已报名通过人员列表
	 * 
	 * @author YanDong
	 * @createDate 2016-1-6
	 */
	@RequestMapping(value = "/findClassUserListYesSignUp")
	public String findClassUserListYesSignUp(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN))
			queryCommond.setIsSuperBusinessAdmin(true);
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 审核状态
			if (PropertyUtil.objectNotEmpty(queryCommond.getSearchSignUpState())) {
				queryCommond.setSearchSignUpState(queryCommond.getSearchSignUpState());
			}
			if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource()) && queryCommond.getClickSource().equals(ClassUser.SOURCE_AUDIT_TWO)) {
				Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
				queryCommond.setSearchDepId(d.getDeptID());
			} else if (!PropertyUtil.objectNotEmpty(queryCommond.getClickSource())) {
				resultState.setState(ResultState.RESULT_STATE_FAIL);
				resultState.setMessage("访问来源不正确！");
				return "";
			}
			List<QueryClassUserBean> resultList = classUserService.findClassUserListYesSignUp(queryCommond);
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		} else {
			resultState.setState(ResultState.RESULT_STATE_FAIL);
			resultState.setMessage("未选中任何班级！");
		}
		return "";
	}

	// 计算百分比的方法
	private String double2precent(double d) {
		int maxValue = 1;
		DecimalFormat ddf1 = new DecimalFormat("#0.00");
		return d >= maxValue ? "100%" : new BigDecimal(ddf1.format(d / maxValue * 100)).setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
	}

	/**
	 * 批量学员报名（单个部门）(委托部委办班在线报名系统)
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author YangJC
	 * @createDate 2016-01-04
	 */
	@RequestMapping(value = "/batchSaveClassUser")
	public String batchSaveClassUser(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态为失败

		// 如果没有传入部门id则默认为在当前管理范围下新增人员
		if (!PropertyUtil.objectNotEmpty(queryCommond.getSearchDepId())) {
			Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			queryCommond.setSearchDepId(d.getDeptID());
		}

		if (PropertyUtil.objectNotEmpty(queryCommond.getSignUpState())) {
			queryCommond.setAuditingState(queryCommond.getSignUpState() == 1 ? ClassUser.NO_AUDITING : ClassUser.IS_AUDITING_Y);
		} else {
			queryCommond.setAuditingState(ClassUser.NO_AUDITING);
		}
		// 设置操作人IP
		queryCommond.setAuditingUserIP(IPUtil.getIP(request));
		// 设置操作人ID
		User cu = (User) request.getSession().getAttribute(SessionConstant.USER_INFO);
		queryCommond.setAuditingUserId(cu.getID());
		String msg = classUserService.batchSaveClassUser(queryCommond);

		if ("添加成功".equals(msg)) {
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage(msg);

			/*
			 * try {
			 *//**
				 * 添加提醒
				 * 
				 * @Date 2016-05-12
				 * @author RongSL
				 * @Params 提醒类型，培训班名称，承办部委名称，提醒分类
				 */
			/*
			 * Department dep = (Department)
			 * request.getSession().getAttribute("currentScope"); //
			 * 单位管理员添加的学员审核状态为未审核，中组部和部委管理员添加的学员审核状态为审核通过
			 * TrainingClassQueryCommond commond = new
			 * TrainingClassQueryCommond();
			 * commond.setSearchClassId(queryCommond.getSearchClassID());
			 * TrainingClassValidCommond tc = (TrainingClassValidCommond)
			 * trainingClassService.findList(commond).get(0); if
			 * (RoleConstants.ROLE_CODE_BW_ADMIN.equals(roleCode)) {// 是否是部委管理员
			 * remindService.remindOperate(Remind.DBM, tc.getClassName(),
			 * dep.getDeptName(), apply.get(0).getDeptName(),
			 * queryCommond.getUserName(), queryCommond.getDutyRemark(),
			 * queryCommond.getSearchClassID(), Remind.PXB); } else {
			 * remindService.remindOperate(Remind.XYBM, tc.getClassName(),
			 * dep.getDeptName(), RoleConstants.ROLE_BW_NAME,
			 * tc.getMinistrieName(), queryCommond.getUserName(),
			 * queryCommond.getSearchClassID(), Remind.PXB); } } catch
			 * (Exception e) { System.out.println("学员报名提醒接口出错了！"); }
			 */
		}

		// 查询该部门下培训班的人数
		// if (PropertyUtil.objectNotEmpty(apply)) {
		// ClassUserQueryCommond quCommond = new ClassUserQueryCommond();
		// quCommond.setSearchClassID(queryCommond.getSearchClassID());
		// quCommond.setSearchDepId(queryCommond.getSearchDepId());
		// quCommond.setAuditingState(ClassUser.IS_AUDITING_N);
		// List<ClassUserValidCommond> classUser = (List<ClassUserValidCommond>)
		// classUserService.findAllList(quCommond);
		// DepartmentUserCondition condition = new DepartmentUserCondition();
		// condition.setSearchDeptIDs(new String[] {
		// queryCommond.getSearchDepId() });
		// condition.setSearchUserActiveState(User.IS_ACTIVE_Y);

		// if (apply.get(0).getAsignCount() >= (classUser.size() + 1)) {
		// /*
		// * String level = queryCommond.getAdministrativeLevel();
		// * ClassPlanApplyValidCommond count = new
		// * ClassPlanApplyValidCommond(); count =
		// * classPlanApplyService.findClassAsignCount(applyCommond); if
		// * (level.equals(ClassPlanApply.LEVEL_CITY)) { if
		// * (count.getAsignCityCount() <= count.getReportedCityCount()) {
		// * resultState.setMessage("此单位可报市级名额已满，请联系承办部委！"); return ""; }
		// * } else if (level.equals(ClassPlanApply.LEVEL_COUNTY)) { if
		// * (count.getAsignCountyCount() <=
		// * count.getReportedCountyCount()) {
		// * resultState.setMessage("此单位可报县级名额已满，请联系承办部委！"); return ""; }
		// * }
		// */
		// String msg = classUserService.batchSaveClassUser(queryCommond);
		//
		// if ("添加成功".equals(msg)) {
		// resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		// resultState.setMessage(msg);
		//
		// try {
		// /**
		// * 添加提醒
		// *
		// * @Date 2016-05-12
		// * @author RongSL
		// * @Params 提醒类型，培训班名称，承办部委名称，提醒分类
		// * */
		// Department dep = (Department)
		// request.getSession().getAttribute("currentScope");
		// // 单位管理员添加的学员审核状态为未审核，中组部和部委管理员添加的学员审核状态为审核通过
		// TrainingClassQueryCommond commond = new TrainingClassQueryCommond();
		// commond.setSearchClassId(queryCommond.getSearchClassID());
		// TrainingClassValidCommond tc = (TrainingClassValidCommond)
		// trainingClassService.findList(commond).get(0);
		// if (RoleConstants.ROLE_CODE_BW_ADMIN.equals(roleCode)) {// 是否是部委管理员
		// remindService.remindOperate(Remind.DBM, tc.getClassName(),
		// dep.getDeptName(), apply.get(0).getDeptName(),
		// queryCommond.getUserName(), queryCommond.getDutyRemark(),
		// queryCommond.getSearchClassID(), Remind.PXB);
		// } else {
		// remindService.remindOperate(Remind.XYBM, tc.getClassName(),
		// dep.getDeptName(), RoleConstants.ROLE_BW_NAME, tc.getMinistrieName(),
		// queryCommond.getUserName(),
		// queryCommond.getSearchClassID(), Remind.PXB);
		// }
		// } catch (Exception e) {
		// System.out.println("学员报名提醒接口出错了！");
		// }
		//
		// } else {
		// resultState.setMessage(msg);
		// }
		// } else {
		// resultState.setMessage("此班级名额已满，若需要增加名额，请联系承办部委。");
		// }
		// } else {
		// resultState.setMessage("该班该部门下没有配置名额，请联系承办部委！");
		// }
		return "";
	}

	/**
	 * 导入报名文件
	 * @author RongSL 2017年8月31日
	 * @throws Exception
	 */
	@SuppressWarnings("rawtypes")
	@RequestMapping(value = "/importSignUpUserForExcel")
	public String importSignUpUserForExcel(ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {

		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		HSSFWorkbook hssfWorkbook = null;
		HSSFSheet sheet = null;
		Row o = null;
		Cell c = null;
		InputStream is = null;
		StringBuffer msg = new StringBuffer("");
		StringBuffer loginIds = new StringBuffer("");
		DecimalFormat df = new DecimalFormat("0");
		int type;
		List<QueryClassUserBean> queryClassUserBeans = new ArrayList<QueryClassUserBean>();
		MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		
		for (MultipartFile multipartFile : fileMap.values()) {
			CommonsMultipartFile commonsMultipartFile = (CommonsMultipartFile) multipartFile;
			FileItem item = commonsMultipartFile.getFileItem();

			try {
				if (!item.getName().substring(item.getName().length() - 3, item.getName().length()).equals("xls")) {
					resultState.setState(ResultState.RESULT_STATE_FAIL);
					resultState.setMessage("导入格式有误，请重新下载模板!");
					return "";
				}
				is = item.getInputStream();
				hssfWorkbook = new HSSFWorkbook(is);
				ClassUserValidCommond cuv;
				int isFalg=1;
				String sexCode=null;
				for (int i = 0; i < hssfWorkbook.getNumberOfSheets(); i++) {
					sheet = (HSSFSheet) hssfWorkbook.getSheetAt(i);
					Iterator<Row> ite = sheet.rowIterator();
					// sheet.getLastRowNum()
					while (ite.hasNext()) {
						o = ite.next();
						if (o.getRowNum() == 0) {
							continue;
						}
						//当学员姓名和身份证都不存在时跳过
						if (!PropertyUtil.objectNotEmpty(o.getCell(0))&&!PropertyUtil.objectNotEmpty(o.getCell(1))) {
							continue;
						}
						if(PropertyUtil.objectNotEmpty(o.getCell(2)))
							sexCode=o.getCell(2).toString().equals("男")?"1078":"1079";
						else
							sexCode=null;
						//查询学员，当身份证存在时跳过姓名验证
						if(PropertyUtil.objectNotEmpty(o.getCell(1))){
							queryCommond.setSearchPaperNum(o.getCell(1).toString());
//							queryCommond.setSearchUserName(null);
							queryCommond.setSearchUserNameNoWhitespace(null);
							queryCommond.setSearchSexCode(sexCode);
						}else{//根据学员姓名查询
//							queryCommond.setSearchUserName(o.getCell(0).toString());
							queryCommond.setSearchUserNameNoWhitespace(o.getCell(0).toString());
							queryCommond.setSearchPaperNum(null);
							queryCommond.setSearchSexCode(sexCode);
						}
						// 根据学员姓名或身份证查询学员
						List userids=classUserDao.findUserInfoByPaperNumOrUserName(queryCommond);
						if(PropertyUtil.objectNotEmpty(userids)){
							/**
							 * 当查询出的学员数量多余1条时说明有重复姓名的学员
							 * TODO 当有重复姓名的学员存在且其中一个学员已在此培训班中报名时，
							 *  则给出提示并跳过此学员，但是和该学员重名的其他学员仍会显示在预报名列表中，并会红名显示出来
							 * */
							if(userids.size()>1){
								for(Object obj:userids){
									queryCommond.setSearchUserID(obj.toString());
									List<QueryClassUserBean> list=classUserDao.findClassUserNoSignUpDetails(queryCommond);
									if(!list.isEmpty()){
										//学员姓名出现重复时添加标识，列表根据此标识进行标红处理
										list.get(0).setIsRepeatName(isFalg);
										queryClassUserBeans.add(list.get(0));
										isFalg++;
									}else{
										msg.append("第"+(o.getRowNum()+1)+"行学员已在培训班中报名，请知晓。%3cbr%3e");
									}
								}
							}else{
								queryCommond.setSearchUserID(userids.get(0).toString());
								List<QueryClassUserBean> list=classUserDao.findClassUserNoSignUpDetails(queryCommond);
								if(!list.isEmpty()){
									list.get(0).setIsRepeatName(999);
									queryClassUserBeans.add(list.get(0));
								}else{
									msg.append("第"+(o.getRowNum()+1)+"行学员已在培训班中报名，请知晓。%3cbr%3e");
								}
							}
						}else{
							msg.append("第"+(o.getRowNum()+1)+"行学员姓名、性别不正确或身份证号未在系统中录入，请知晓。%3cbr%3e");
						}
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
				resultState.setState(ResultState.RESULT_STATE_FAIL);
				resultState.setMessage("系统错误，请联系管理员!");
			}
		}
		resultState.setMessage(msg.toString());
		if (PropertyUtil.objectNotEmpty(queryClassUserBeans)||PropertyUtil.objectNotEmpty(resultState.getMessage())) {
			//对学员进行排序，重复学员显示在最前面
			Collections.sort(queryClassUserBeans, new Comparator<QueryClassUserBean>() {
	            public int compare(QueryClassUserBean o1, QueryClassUserBean o2) {
	                return o1.getIsRepeatName().compareTo(o2.getIsRepeatName());
	            }
	        });
			// 将解析结果暂存到session
			request.getSession().setAttribute("signUpUsers", queryClassUserBeans);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			queryCommond.setResultList(queryClassUserBeans);
		} else {
			resultState.setMessage("无可报名人员，学员帐号有误或者已经报名。");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}
		return "";
	}

	/**
	 * Excel导入单位报名(委托部委办班在线报名系统)
	 * 
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author YangJC
	 * @date 2016-01-06
	 */
	@RequestMapping(value = "/importClassUser", method = { org.springframework.web.bind.annotation.RequestMethod.POST })
	public String importClassUser(Model model, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认失败
		String msg = "";
		MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		for (MultipartFile mf : fileMap.values()) {
			CommonsMultipartFile cmf = (CommonsMultipartFile) mf;
			FileItem file = cmf.getFileItem();
			String name = file.getName();
			if (name == null || name.trim().equals("")) {
				msg = "您使用的导入模板不正确，请确认后重新导入！";
			} else {
				String fileType = name.substring(name.lastIndexOf("."));
				if (!".xls".equals(fileType)) {
					msg = "导入文件格式错误，应为.xls格式，请修改后重新导入。";
				} else {
					byte[] bytes = mf.getBytes();
					/*
					 * ByteArrayOutputStream bos = new
					 * ByteArrayOutputStream(1000); byte[] b = new byte[1000];
					 * int n; while ((n = item.read(b)) != -1) { bos.write(b, 0,
					 * n); } item.close(); bos.close(); bytes =
					 * bos.toByteArray();
					 */
					if (bytes.length == 0) {
						msg = "您使用的导入模板不正确，请确认后重新导入！";
					} else {
						// 写解析bytes代码
						/*
						 * InputStream in = null; ExcelSheet sheet = null; in =
						 * new ByteArrayInputStream(bytes);
						 */
						// 读取excel
						// sheet=excelUtils.readFile(in);
						msg = classUserService.importClassUser(file, response, request);
					}
				}
			}
		}
		if ("".equals(msg)) {
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("导入成功！");
		} else {
			resultState.setMessage(msg);
		}
		return "";
	}

	/**
	 * 单位管理员导出培训班下人员信息(委托部委办班在线报名系统)
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author YangJC
	 * @createDate 2016-1-7
	 */
	@RequestMapping(value = "/excelSelectedUserList")
	public String excelSelectedUserList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		List<QueryClassUserBean> resultList = null;

		String title = null;
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN))
			queryCommond.setIsSuperBusinessAdmin(true);

		Department currentScope = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		Role currentrole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		// 审核状态
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchSignUpState())) {
			queryCommond.setSearchSignUpState(queryCommond.getSearchSignUpState());
		}

		List<TrainingClassQueryBean> rtList = null;
		TrainingClassQueryCommond qCommond = new TrainingClassQueryCommond();
		if (!PropertyUtil.objectNotEmpty(qCommond.getLimit())) {
			qCommond.setLimit(-1);
		}
		ClassUserSheet classUserSheet = new ClassUserSheet();
		// 判断点击来源
		if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource()) && queryCommond.getClickSource().equals(ClassUser.SOURCE_AUDIT_TWO)) {
			classUserSheet.setExprotFormatName("classAllUserListForSignupExportConfig");
			// 培训班报名需要加入管理范围
			queryCommond.setSearchDepId(currentScope.getDeptID());
			// 判断导出方式
			if (PropertyUtil.objectNotEmpty(queryCommond.getExpState()) && queryCommond.getExpState().toString().equals("2")) {

				qCommond.setSearchRoleCode(currentRole.getRoleCode());
				if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassNum())) {
					qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
				}
				qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
				qCommond.setSearchSponsorId(currentScope.getDeptID());
				qCommond.setSearchClassTrainingType(DeptConstants.ZDBMJG);
				qCommond.setTreePath(currentScope.getTreepath());
				qCommond.setSearchClassIds(queryCommond.getSearchClassIds());

				if (currentScope.getDeptID().equals(DeptConstants.SWZZB)) {
					qCommond.setUnitLevel(DeptConstants.SWZZB);
				} else {
					Department dept = classUserDao.find(Department.class, currentScope.getDeptID());
					qCommond.setUnitLevel(dept.getAdminLevelCode());
				}
				qCommond.setLimit(-1);
				rtList = trainingClassService.findThematicClassList(qCommond);
			}
		} else if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource()) && queryCommond.getClickSource().equals(ClassUser.SOURCE_AUDIT_ONE)) {
			classUserSheet.setExprotFormatName("classAllUserListExportConfig");
			// 判断导出方式
			if (PropertyUtil.objectNotEmpty(queryCommond.getExpState()) && queryCommond.getExpState().toString().equals("1")) {
				// 当前登录人
				qCommond.setSearchSponsorId(currentScope.getDeptID());
				// 传递当前管理范围单位ID
				qCommond.setDeptId(currentScope.getDeptID());

				qCommond.setSearchRoleCode(currentrole.getCode());

				// 传递当前管理范围单位ID
				if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassNum())) {
					qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
				}
				qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
				qCommond.setSearchClassTrainingType(DeptConstants.ZDBMJG);
				qCommond.setLimit(-1);
				rtList = trainingClassService.findThematicClassList(qCommond);
			}
		} else if(PropertyUtil.objectNotEmpty(queryCommond.getClickSource()) && queryCommond.getClickSource().equals(ClassUser.SOURCE_AUDIT_THREE)){
			classUserSheet.setExprotFormatName("classAttendanceSheetExportConfig");
			// 培训班报名需要加入管理范围
			queryCommond.setSearchDepId(currentScope.getDeptID());
			// 判断导出方式
			if (PropertyUtil.objectNotEmpty(queryCommond.getExpState()) && queryCommond.getExpState().toString().equals("2")) {

				qCommond.setSearchRoleCode(currentRole.getRoleCode());
				if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassNum())) {
					qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
				}
				qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
				qCommond.setSearchSponsorId(currentScope.getDeptID());
				qCommond.setSearchClassTrainingType(DeptConstants.ZDBMJG);
				qCommond.setTreePath(currentScope.getTreepath());
				qCommond.setSearchClassIds(queryCommond.getSearchClassIds());

				if (currentScope.getDeptID().equals(DeptConstants.SWZZB)) {
					qCommond.setUnitLevel(DeptConstants.SWZZB);
				} else {
					Department dept = classUserDao.find(Department.class, currentScope.getDeptID());
					qCommond.setUnitLevel(dept.getAdminLevelCode());
				}
				qCommond.setLimit(-1);
				rtList = trainingClassService.findThematicClassList(qCommond);
			}
		}else if (!PropertyUtil.objectNotEmpty(queryCommond.getClickSource())) {
			resultState.setState(ResultState.RESULT_STATE_FAIL);
			resultState.setMessage("访问来源不正确！");
			return "";
		}

		// 判断导出方式
		if (PropertyUtil.objectNotEmpty(queryCommond.getExpState()) && queryCommond.getExpState().toString().equals("1")) {
			String classIds[] = new String[rtList.size()];
			for (int i = 0; i < rtList.size(); i++) {
				classIds[i] = rtList.get(i).getClassId();
			}
			queryCommond.setSearchClassIds(classIds);
		} else if (!PropertyUtil.objectNotEmpty(queryCommond.getSearchClassIds())) {
			resultState.setState(ResultState.RESULT_STATE_FAIL);
			resultState.setMessage("未选中任何班级！");
			return "";
		}
		if (!PropertyUtil.objectNotEmpty(queryCommond.getSearchClassIds())) {
			resultList = new ArrayList<QueryClassUserBean>();
		} else {
			resultList = classUserService.findClassUserListYesSignUpPerfect(queryCommond);
		}
		List<ExportClassUserBean> exportList = new ArrayList<ExportClassUserBean>();
		for (QueryClassUserBean queryClassUserBean : resultList) {
			ExportClassUserBean userBean = new ExportClassUserBean();
			BeanUtils.copyProperties(queryClassUserBean, userBean);
			exportList.add(userBean);
		}
		ClassUserExport classUserExport = new ClassUserExport();
		classUserExport.setExpClassUserBeanList(exportList);
		classUserSheet.setExportObject(classUserExport);
		// TrainingClassQueryCommond trainingClassQueryCommond = new
		// TrainingClassQueryCommond();
		// trainingClassQueryCommond.setSearchClassId(queryCommond.getSearchClassID());
		Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		if(PropertyUtil.objectNotEmpty(queryCommond.getClickSource()) && queryCommond.getClickSource().equals(ClassUser.SOURCE_AUDIT_THREE)){
			title = "签到表";
		}else
			title = "参训学员汇总表";
		classUserSheet.setSheetName("学员名单");
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
		return "";
	}

	/**
	 * 导出单个班学员(委托部委办班在线报名系统)
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2016-1-7
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/exportClassUserListByClassId")
	public void exportClassUserListByClassId(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// Role currentRole = (Role)
		// request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		// if
		// (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN))
		// queryCommond.setIsSuperBusinessAdmin(true);
		// if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
		// queryCommond.setLimit(100);// 不翻页
		// com.eorchis.module.security.cas.domain.Department d =
		// (com.eorchis.module.security.cas.domain.Department)
		// request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		// queryCommond.setSearchDepId(d.getDeptID());
		// // List<QueryClassUserBean>
		// // list=classUserService.findTrainingClassUserList(queryCommond);
		// List<QueryClassUserBean> list =
		// classUserService.findClassUserListByAttendanceState(queryCommond);
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN))
			queryCommond.setIsSuperBusinessAdmin(true);

		// 审核状态
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchSignUpState())) {
			queryCommond.setSearchSignUpState(queryCommond.getSearchSignUpState());
		}

		// 判断点击来源
		if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource()) && queryCommond.getClickSource().equals(ClassUser.SOURCE_AUDIT_TWO)) {
			Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			queryCommond.setSearchDepId(d.getDeptID());
		} else if (!PropertyUtil.objectNotEmpty(queryCommond.getClickSource())) {
			resultState.setState(ResultState.RESULT_STATE_FAIL);
			resultState.setMessage("访问来源不正确！");
		}

		// 判断导出方式
		if (PropertyUtil.objectNotEmpty(queryCommond.getExpState()) && queryCommond.getExpState().toString().equals("1")) {

		} else if (!PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			resultState.setState(ResultState.RESULT_STATE_FAIL);
			resultState.setMessage("未选中任何班级！");
		}
		List<QueryClassUserBean> list = classUserService.findClassUserListYesSignUpPerfect(queryCommond);
		List<ExportClassUserBean> exportList = new ArrayList<ExportClassUserBean>();
		for (QueryClassUserBean queryClassUserBean : list) {
			ExportClassUserBean userBean = new ExportClassUserBean();
			BeanUtils.copyProperties(queryClassUserBean, userBean);
			exportList.add(userBean);
		}
		ClassUserExport classUserExport = new ClassUserExport();
		classUserExport.setExpClassUserBeanList(exportList);
		ClassUserSheet classUserSheet = new ClassUserSheet();
		classUserSheet.setExportObject(classUserExport);
		classUserSheet.setExprotFormatName("classUserListExportConfig2");
		TrainingClassQueryCommond trainingClassQueryCommond = new TrainingClassQueryCommond();
		trainingClassQueryCommond.setSearchClassId(queryCommond.getSearchClassID());
		List<TrainingClassValidCommond> trainingClass = (List<TrainingClassValidCommond>) trainingClassService.findAllList(trainingClassQueryCommond);
		classUserSheet.setSheetName(trainingClass.get(0).getClassName());
		Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = trainingClass.get(0).getClassName() + "_学员名单";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 导出多个班学员(委托部委办班在线报名系统)
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @throws Exception
	 * @author NingSS
	 * @date 2016-1-7
	 */
	@RequestMapping(value = "/exportAllClassUserList")
	public void exportAllClassUserList(@ModelAttribute("result") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response) throws Exception {
		// 查询班级
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListNoPage(qCommond);
		// 查询人员
		List<String> classIdList = new ArrayList<String>();// 班级id集合
		ClassUserQueryCommond queryCommond = new ClassUserQueryCommond();
		if (PropertyUtil.objectNotEmpty(resultList) && resultList.size() > 0) {
			for (TrainingClassQueryBean bean : resultList) {
				classIdList.add(bean.getClassId());
			}
			queryCommond.setSearchClassIDs(classIdList);
		}
		List<QueryClassUserBean> beanList = classUserService.findTrainingClassUserList(queryCommond);
		// 将QueryClassUserBean转成ExportClassUserBean
		List<ExportClassUserBean> exrbeanList = new ArrayList<ExportClassUserBean>();
		if (PropertyUtil.objectNotEmpty(beanList) && beanList.size() > 0) {
			for (QueryClassUserBean classUserbean : beanList) {
				ExportClassUserBean extBean = new ExportClassUserBean();
				org.springframework.beans.BeanUtils.copyProperties(classUserbean, extBean);
				exrbeanList.add(extBean);
			}
		}
		// 导出excel
		ClassUserExport classUserExport = new ClassUserExport();
		classUserExport.setExpClassUserBeanList(exrbeanList);
		ClassUserSheet classUserSheet = new ClassUserSheet();
		classUserSheet.setExportObject(classUserExport);
		classUserSheet.setExprotFormatName("exportAllClassUserListConfig");
		classUserSheet.setSheetName("学员名单");
		Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "学员名单";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * @param commond
	 * @return
	 * @throws Exception
	 * @author RongSL
	 * @createDate 2016-01-15
	 */
	@RequestMapping(value = "/getParentDepartmentTree")
	public @ResponseBody List<JsonTreeBean> getParentDepartmentTree(DepartmentTreeCommond commond, HttpServletRequest request) throws Exception {
		List<JsonTreeBean> result = new ArrayList<JsonTreeBean>();
		String classId = request.getParameter("classIdd");
		// 取出当前管理范围
		Department casDept = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		if (PropertyUtil.objectNotEmpty(commond.getNode()) && PropertyUtil.objectNotEmpty(casDept)) {
			if (PropertyUtil.objectNotEmpty(commond.getNode()))
				commond.setNode(commond.getNode());
			else
				commond.setNode(casDept.getDeptID());
			DepartmentTreeCondition condition = new DepartmentTreeCondition();
			BeanUtils.copyProperties(commond, condition);
			condition.setFindLeapNode(true);
			List<JsonTreeBean> list = departmentTreeService.doProcess(condition);
			if (PropertyUtil.objectNotEmpty(commond.getNode()) && commond.getNode().equals("1")) {
				JsonTreeBean rootBean = new JsonTreeBean();
				rootBean.setText("北京市");
				rootBean.setLeaf(false);
				rootBean.setId("1");
				rootBean.setChildren(list);
				rootBean.setState("close");
				rootBean.setExpandable(true);
				result.add(rootBean);
				return result;
			}
			return list;
		}
		return result;
	}

	/**
	 * 驳回撤销报名
	 * 
	 * @param commond
	 * @return
	 * @throws Exception
	 * @author LongJZ
	 * @createDate 2016-1-26
	 */
	@RequestMapping(value = "/rejectDeleteUser")
	public String rejectDeleteUser(@ModelAttribute("result") ClassUserValidCommond commond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (PropertyUtil.objectNotEmpty(commond.getUserIds())) {
			classUserService.rejectDeleteUser(commond);
			resultState.setMessage("驳回成功!");

			String roleCode = ((Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE)).getCode();
			if (RoleConstants.ROLE_CODE_BW_ADMIN.equals(roleCode)) {
				/**
				 * 添加提醒
				 * 
				 * @Date 2016-05-12
				 * @author RongSL
				 * @Params 提醒类型，培训班名称，承办部委名称，提醒分类
				 */
				try {
					ClassUserQueryCommond cq = new ClassUserQueryCommond();
					cq.setSearchUserIds(commond.getUserIds());
					Department dep = (Department) request.getSession().getAttribute("currentScope");
					Object[] o = null;
					for (Object obj : classUserService.findClassInfo(cq)) {
						o = (Object[]) obj;
						remindService.remindOperate(Remind.BMSH, (String) o[0], dep.getDeptCode(), RoleConstants.ROLE_BW_NAME, (String) o[1], (String) o[2], (String) o[3], "驳回", "撤销报名申请", (String) o[4], Remind.PXB);
					}
				} catch (Exception e) {
					System.out.println("报名审核提醒接口出错了！");
				}
			}

		} else {
			resultState.setState(ResultState.RESULT_STATE_FAIL);
			resultState.setMessage("未选中任何人员!");
		}
		return "";
	}

	/**
	 * 查看驳回原因
	 * 
	 * @param commond
	 * @return
	 * @throws Exception
	 * @author LongJZ
	 * @createDate 2016-1-26
	 */
	@RequestMapping(value = "/findRejectReason")
	public String findRejectReason(@ModelAttribute("result") ClassUserValidCommond commond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		QueryClassUserBean result = classUserService.findRejectReason(commond);
		commond.setRejectReason(result.getRejectReason());
		return "";
	}

	/**
	 * 学员评价
	 * 
	 * @param commond
	 * @return
	 * @throws Exception
	 * @author RongSL
	 * @createDate 2016-2-23
	 */
	@RequestMapping(value = "/userAppraise")
	public String userAppraise(ClassUserQueryCommond queryCommond, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassUserIds())) {
			classUserService.userAppraise(queryCommond);
			resultState.setMessage("评价成功！");
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} else {
			resultState.setMessage("评价失败！");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}
		return "";
	}

	/**
	 * 学员表现查看（地方管理员用）
	 * 
	 * @param commond
	 * @return
	 * @throws Exception
	 * @author RongSL
	 * @createDate 2016-2-23
	 */
	@RequestMapping(value = "/userAppraiseShow")
	public String userAppraiseShow(HttpServletRequest request, @ModelAttribute("resultList") ClassUserQueryCommond queryCommond, @ModelAttribute("resultState") ResultState resultState) throws Exception {

		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		queryCommond.setSearchDepId(d.getDeptID());
		List<QueryClassUserBean> list = classUserService.userAppraiseShow(queryCommond);
		queryCommond.setResultList(list);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		resultState.setMessage("查询成功");
		return "";
	}

	/**
	 * 解除学员锁定
	 * 
	 * @param commond
	 * @throws Exception
	 * @author RongSL
	 * @createDate 2016-2-23
	 */
	@RequestMapping(value = "/openLockUserAppraise")
	public String openLockUserAppraise(ClassUserQueryCommond queryCommond, @ModelAttribute("resultState") ResultState resultState, HttpServletRequest request) throws Exception {
		classUserService.openLockUserAppraise(queryCommond);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		resultState.setMessage("解锁成功!");

		try {
			/**
			 * 添加提醒
			 * 
			 * @Date 2016-05-12
			 * @author RongSL
			 * @Params 提醒类型，培训班名称，承办部委名称，提醒分类
			 */
			Department dep = (Department) request.getSession().getAttribute("currentScope");
			ClassUserQueryCommond c = null;
			for (String id : queryCommond.getSearchClassUserIds()) {
				c = new ClassUserQueryCommond();
				c.setSearchClassUserId(id);
				List<?> list = classUserService.findClassInfo(queryCommond);
				Iterator<?> it = list.iterator();
				Object[] s = null;
				while (it.hasNext()) {
					s = (Object[]) it.next();
					remindService.remindOperate(Remind.XYPJJS, (String) s[0], dep.getDeptName(), (String) s[1], (String) s[4], Remind.PXB);
				}
			}
		} catch (Exception e) {
			System.out.println("解除学员锁定出错了！");
		}
		return "";
	}

	/**
	 * 查看学员表现（单个学员）
	 * 
	 * @param commond
	 * @return
	 * @throws Exception
	 * @author RongSL
	 * @createDate 2016-2-23
	 */
	@RequestMapping(value = "/userAppraiseShowOne")
	public String userAppraiseShowOne(@ModelAttribute("result") @Valid ClassUserCommond queryCommond, @ModelAttribute("resultState") ResultState resultState, HttpServletRequest request, HttpServletResponse response) throws Exception {
		List<QueryClassUserBean> list = classUserService.userAppraiseShowOne(queryCommond);
		queryCommond.setAppraise(list.get(0).getAppraise());
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		resultState.setMessage("查询成功!");
		return "";
	}

	/**
	 * 更新人员考勤状态
	 * 
	 * @param queryCommond
	 * @return
	 * @throws Exception
	 * @author RongSL
	 * @createDate 2016-9-18
	 */
	@RequestMapping("updateUserAttendanceState")
	public void updateUserAttendanceState(ClassUserQueryCommond queryCommond, @ModelAttribute("resultState") ResultState resultState, HttpServletRequest request) throws Exception {
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchUserIds())) {
			if (classUserService.updateUserAttendanceState(queryCommond)) {
				resultState.setMessage("更新成功！");
				resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			} else {
				resultState.setMessage("更新失败，请联系管理员！");
				resultState.setState(ResultState.RESULT_STATE_FAIL);
			}
		} else {
			resultState.setMessage("缺少参数吗，更新失败！");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}
	}

	/**
	 * 批量增量人员
	 * 
	 * @author RongSL
	 * @date 2017-01-09
	 */
	@RequestMapping("selectUserSave")
	public void selectUserSave(ClassUserQueryCommond queryCommond, @RequestBody List<QueryClassUserBean> classList, @ModelAttribute("resultState") ResultState resultState, HttpServletRequest request) throws Exception {
		User cu = (User) request.getSession().getAttribute(SessionConstant.USER_INFO);
		queryCommond.setAuditingUserId(cu.getUserId());
		if (PropertyUtil.objectNotEmpty(classList) && PropertyUtil.objectNotEmpty(classList.get(0)) && PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			queryCommond.setAuditingUserIP(IPUtil.getIP(request));
			queryCommond.setClassList(classList);
			try {
				if (!PropertyUtil.objectNotEmpty(queryCommond.getAuditingState())) {
					queryCommond.setAuditingState(ClassUser.NO_AUDITING);
				}
				classUserService.selectUserSave(queryCommond);
				resultState.setMessage("报名成功！");
				resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			} catch (Exception e) {
				e.printStackTrace();
				resultState.setMessage("报名异常，请关闭后重新尝试!");
				resultState.setState(ResultState.RESULT_STATE_FAIL);
			}
		} else {
			resultState.setMessage("缺少参数!");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}
	}

	/**
	 * 更新学员状态
	 * 
	 * @param queryCommond
	 * @throws Exception
	 * @author RongSL
	 * @createDate 2017-01-13
	 */
	@RequestMapping(value = "/updateUserState")
	public String updateUserState(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassUserIds()) && queryCommond.getSearchClassUserIds().length > 0) {
			classUserService.updateUserAuditState(queryCommond);
		}
		return null;
	}

	/**
	 * 更细考核学时
	 * 
	 * @Date 2017-02-22
	 * @author RongSL
	 */
	@RequestMapping(value = "/updateTrainingClassUserH")
	public String updateTrainingClassUserH(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassUserId())) {
			classUserService.updateTrainingClassUserH(queryCommond);
			resultState.setMessage("更新成功！");
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			return "";
		}
		resultState.setMessage("缺少参数，请联系管理员！");
		return "";
	}

	/**
	 * 更细考核备注
	 * 
	 * @Date 2017-02-22
	 * @author RongSL
	 */
	@RequestMapping(value = "/updateTrainingClassUserB")
	public String updateTrainingClassUserB(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassUserId())) {
			classUserService.updateTrainingClassUserB(queryCommond);
			resultState.setMessage("更新成功！");
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			return "";
		}
		resultState.setMessage("缺少参数，请联系管理员！");
		return "";
	}

	/**
	 * 更细考核结果
	 * 
	 * @Date 2017-05-15
	 * @author RongSL
	 */
	@RequestMapping(value = "/updateTrainingClassUserR")
	public String updateTrainingClassUserR(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassUserId())) {
			classUserService.updateTrainingClassUserR(queryCommond);
			resultState.setMessage("更新成功！");
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			return "";
		}
		resultState.setMessage("缺少参数，请联系管理员！");
		return "";
	}

	/**
	 * 更新考核状态
	 * 
	 * @author RongSL
	 * @Date 2017-02-23
	 */
	@RequestMapping(value = "/updateExaminationState")
	public void updateExaminationState(@ModelAttribute("result") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态失败
		try {
			if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
				classUserService.updateExaminationState(queryCommond);
				resultState.setMessage("操作成功！");
				resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			} else {
				resultState.setMessage("缺少参数，请联系管理员！");
			}
		} catch (Exception e) {
			e.printStackTrace();
			resultState.setMessage("系统异常，请联系管理员！");
		}
		PrintWriter pw = response.getWriter();
		pw.append(JSON.toJSONString(resultState));
		pw.flush();
		pw.close();
	}

	/**
	 * 导出考核人员表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @throws Exception
	 * @author RongSL
	 * @createDate 2017-02-23
	 */
	@RequestMapping(value = "/exportExcelExaminationUserList")
	public String exportExcelExaminationUserList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		List<QueryClassUserBean> resultList = null;
		ClassUserSheet classUserSheet = new ClassUserSheet();
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		if (attributeConverter != null) {
			parameterValueConver(queryCommond, request, attributeConverter);
		}
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN))
			queryCommond.setIsSuperBusinessAdmin(true);
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 如果是单位管理员 则查询管理范围下的人员
			if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource())) {
				if (!ClassUserQueryCommond.CLICK_SOURCE.equals(queryCommond.getClickSource().toString())) {
					Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
					queryCommond.setSearchDepId(d.getDeptID());
				} else {
					queryCommond.setSearchDepId(null);
				}
			}
			// 至查询报名通过人员
			Integer searchSignUpState[] = new Integer[] { 1, 5 };
			queryCommond.setSearchSignUpState(searchSignUpState);
			queryCommond.setLimit(-1);
			resultList = classUserService.findClassUserListExaminationList(queryCommond);
		} else {
			resultState.setMessage("缺少参数，请联系管理员！");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
			return "";
		}
		List<ExportClassUserBean> exportList = new ArrayList<ExportClassUserBean>();
		for (QueryClassUserBean queryClassUserBean : resultList) {
			ExportClassUserBean userBean = new ExportClassUserBean();
			BeanUtils.copyProperties(queryClassUserBean, userBean);
			BaseData bd;
			Map<String, BaseData> baseDataMap = baseDataCacheUtil.getBaseData();
			if (PropertyUtil.objectNotEmpty(userBean.getExaminationRemark())) {
				bd = baseDataMap.get(userBean.getExaminationRemark());
				if (PropertyUtil.objectNotEmpty(bd) && PropertyUtil.objectNotEmpty(bd.getDataID())) {
					userBean.setExaminationRemark(bd.getDataName());
				}
			}
			if (PropertyUtil.objectNotEmpty(userBean.getExaminationResult())) {
				bd = baseDataMap.get(userBean.getExaminationResult());
				if (PropertyUtil.objectNotEmpty(bd) && PropertyUtil.objectNotEmpty(bd.getDataID())) {
					userBean.setExaminationResult(bd.getDataName());
				}
			}
			exportList.add(userBean);
		}
		ClassUserExport classUserExport = new ClassUserExport();
		classUserExport.setExpClassUserBeanList(exportList);
		classUserSheet.setExportObject(classUserExport);
		classUserSheet.setExprotFormatName("UserExaminationExportConfig");
		Sheet[] sheetArray = new Sheet[] { classUserSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "考核学员表";
		classUserSheet.setSheetName("学员名单");
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
		return "";
	}

	/**
	 * 报名通过情况
	 * 
	 * @author RongSL 2017年5月15日
	 */
	@RequestMapping("/signSituation")
	public void signSituation(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态失败
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			classUserService.signSituation(queryCommond);
			resultState.setMessage(classUserService.signSituation(queryCommond));
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} else {
			resultState.setMessage("缺少参数，请联系管理员！");
		}
		PrintWriter pw = response.getWriter();
		pw.append(JSON.toJSONString(resultState));
		pw.flush();
		pw.close();
	}

	/**
	 * 判断手机号在当前班级里是否重复出现
	 * 
	 * @author RongSL 2017年6月4日
	 */
	@RequestMapping("/checkPhoneRepeat")
	public void checkPhoneRepeat(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认状态失败
		List<QueryClassUserBean> list = classUserService.findClassUserListNoSignUp(queryCommond);
		if (list.isEmpty()) {
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		}
		PrintWriter pw = response.getWriter();
		pw.append(JSON.toJSONString(resultState));
		pw.flush();
		pw.close();
	}

	/**
	 * 学习心得列表
	 * 
	 * @author RongSL 2017年9月20日
	 * @throws Exception
	 */
	@RequestMapping("/findLearningExperienceList")
	public String findLearningExperienceList(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		User cu = (User) request.getSession().getAttribute(SessionConstant.USER_INFO);
		if (PropertyUtil.objectNotEmpty(cu)) {
			queryCommond.setSearchUserID(cu.getID());
			List<QueryClassUserBean> list = classUserService.findLearningExperienceList(queryCommond);
			for (QueryClassUserBean q : list) {
				if (PropertyUtil.objectNotEmpty(q.getAttachmentID())) {
					q.setFileSize(UnitConvertUtil.getPrintSize(Long.parseLong(q.getFileSize().toString())));
				}
			}
			queryCommond.setResultList(list);
		}
		return "forward:../../portal/project/classuser/listLearningExperience.jsp";
	}

	/**
	 * 批量下载心得
	 * 
	 * @author RongSL 2017年9月22日
	 * @throws Exception
	 */
	@RequestMapping("/batchDownloadLearning")
	public void batchDownloadLearning(HttpServletRequest request, ClassUserQueryCommond queryCommond, HttpServletResponse response) throws Exception {
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN))
			queryCommond.setIsSuperBusinessAdmin(true);
		// 判断传入参数
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassID())) {
			// 如果是单位管理员 则查询管理范围下的人员
			if (PropertyUtil.objectNotEmpty(queryCommond.getClickSource())) {
				if (!ClassUserQueryCommond.CLICK_SOURCE.equals(queryCommond.getClickSource().toString())) {
					Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
					queryCommond.setSearchDepId(d.getDeptID());
				} else {
					queryCommond.setSearchDepId(null);
				}
			}
			// 如果功能是 点击报名人数展开_已选报名列表 那么把单位id传过来。可以看下dao层
			List<QueryClassUserBean> resultList = classUserService.findClassUserListNoSignUp(queryCommond);
			if (PropertyUtil.objectNotEmpty(resultList) && !resultList.isEmpty()) {
				String className = queryCommond.getSearchClassName()+"-学员心得.zip";
				response.setContentType("application/x-zip-compressed");// 设置response内容的类型
				response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(className, "UTF-8"));// 设置头部信息
				AttachmentCommond attachment = new AttachmentCommond();
				InputStream is = null;
				byte[] buf = new byte[1024];
				ZipOutputStream out = new ZipOutputStream(response.getOutputStream());
				for (QueryClassUserBean qcu : resultList) {
					attachment.setAttachmentID(qcu.getAttachmentID());
					attachment = (AttachmentCommond) attachmentService.find(attachment.getAttachmentID());
					String fileName = qcu.getLoginID()+"-"+attachment.getPrimevalFileName();
					//查询文件并转为输入流
					is = classUserService.getAttachmentContent(attachment).getBinaryStream();
					//设置文件名称
					out.putNextEntry(new ZipEntry(fileName));
					// 写入文件至zip
					int len;
					while ((len = is.read(buf)) > 0) {
						out.write(buf, 0, len);
					}
					// 关闭单个文件流
					out.closeEntry();
					is.close();
				}
				out.close();
			}else{
				response.setCharacterEncoding("GB2312"); 
				PrintWriter pw=response.getWriter();
				pw.write("<script>alert('暂无数据');window.opener='';window.open('', '_self', '');window.close();</script>");
				pw.close();
			}
		}
	}
	
	/**
	 * 判断是否在5个轮训班
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/isFiveClass")
	public String isFiveClass(@ModelAttribute("result") ClassUserQueryCommond queryCommond,
			HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute("resultState") ResultState resultState)throws Exception{
		resultState.setState(ResultState.RESULT_STATE_FAIL);//默认状态为失败
		if(PropertyUtil.objectNotEmpty(queryCommond.getSearchUserIds())&&PropertyUtil.objectNotEmpty(queryCommond.getSearchClassIds())){
			List<QueryClassUserBean> beans = classUserService.isFiveClass(queryCommond);
			if(beans != null && beans.size()>0){
//				userNames = userNames.substring(0, userNames.length()-1);
				String meg = "";
				for(QueryClassUserBean bean : beans){
					meg = meg + bean.getUserName()+"，已报“"+bean.getClassName()+"”，不能重复报名，请撤销报名后，重新报名。<br/>";
				}
				resultState.setMessage(meg);
			}else{
				resultState.setMessage("");
			}
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		}else{
			resultState.setMessage("缺少参数，请联系管理员！");
		}
		return "";
	}
	
	/**
	 * 学员学时统计
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/findUserHourStatistics")
	public String findUserHourStatistics(@ModelAttribute("resultList") ClassUserQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认是失败状态
		//获取用户信息
		User user=(User) request.getSession().getAttribute(SessionConstant.USER_INFO);
		queryCommond.setSearchUserID(user.getUserId());
//		queryCommond.setDutyLevelId(user.getDutyLevelId());
		List<QueryClassUserBean> list=classUserService.findUserClassTypeHourList(queryCommond);
	
		if(!PropertyUtil.objectNotEmpty(queryCommond.getSearchYear())){
			QueryClassUserBean ucu;
			Double ztbHours = 0.0;
			Double zhutbHours = 0.0;
			Double zhongydxHours = 0.0;
			Double jwpxHours = 0.0;
			Double qitHours = 0.0;
			Double totalHours = 0.0;
			Double zxHours = 0.0;
			Double zxZsHours = 0.0;
			for(QueryClassUserBean qcu:list){
				ztbHours += qcu.getZtbHour();
				zhutbHours += qcu.getZhutbHour();
				zhongydxHours += qcu.getZhongydxHour();
				jwpxHours += qcu.getJwpxHour();
				qitHours += qcu.getQitHour();
				zxHours += qcu.getZxHour();
				zxZsHours += qcu.getZxZsHour();
				totalHours +=  qcu.getZtbHour()+qcu.getZhutbHour()+qcu.getZhongydxHour()+qcu.getJwpxHour()+qcu.getQitHour()+qcu.getZxZsHour();
			}
			ucu=new QueryClassUserBean();
			ucu.setHourYear("合计");
			ucu.setZhongydxHour(zhongydxHours);
			ucu.setZtbHour(ztbHours);
			ucu.setZhutbHour(zhutbHours);
			ucu.setJwpxHour(jwpxHours);
			ucu.setQitHour(qitHours);
			ucu.setZxHour(zxHours);
			ucu.setZxZsHour(zxZsHours);
			ucu.setHours(totalHours);
			list.add(ucu);
		}
		queryCommond.setResultList(list);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		resultState.setMessage("查询成功！");
		return "";
	}
	
	//封装统计数据
	public List<UserClassTypeHour> buildUserHourStatistics(ClassUserQueryCommond queryCommond)throws Exception{
		//培训学时统计集合
		Map<String, List<UserClassTypeHour>> map = classUserService.findClassUserTotal(queryCommond);
		//在线学习学时列表
		List<UserClassTypeHour> zxHourList = classUserService.findZxHourList(queryCommond, queryCommond.getYear());
		
		List<UserClassTypeHour> list=new ArrayList<UserClassTypeHour>();
		UserClassTypeHour uct;
		DecimalFormat fmt = new DecimalFormat("##0.0");
		//培训学时集合
		List<UserClassTypeHour> ztbBean = map.get("ztb");
		List<UserClassTypeHour> zhutbBean = map.get("zhutb");
		List<UserClassTypeHour> zhongydxBean = map.get("zhongydx");
		List<UserClassTypeHour> jwpxBean = map.get("jwpx");
		List<UserClassTypeHour> qitBean = map.get("qit");
		Double ztbHours = 0.0;
		Double zhutbHours = 0.0;
		Double zhongydxHours = 0.0;
		Double jwpxHours = 0.0;
		Double qitHours = 0.0;
		Double totalHours = 0.0;
		Double zxHours = 0.0;
		Double zxZsHours = 0.0;
		Double hours = 0.0;
		for(int i=0;i<ztbBean.size();i++){
			uct=new UserClassTypeHour();
			hours = ztbBean.get(i).getHours()+zhutbBean.get(i).getHours()+zhongydxBean.get(i).getHours()+jwpxBean.get(i).getHours()+qitBean.get(i).getHours()+zxHourList.get(i).getZxZsHour();
			ztbHours +=  ztbBean.get(i).getHours();
			zhutbHours +=  zhutbBean.get(i).getHours();
			zhongydxHours +=  zhongydxBean.get(i).getHours();
			jwpxHours +=  jwpxBean.get(i).getHours();
			qitHours +=  qitBean.get(i).getHours();
			zxHours += zxHourList.get(i).getZxHour();
			zxZsHours +=  zxHourList.get(i).getZxZsHour();
			totalHours += hours;
			ztbBean.get(i).getHourYear();
			uct.setHourYear(ztbBean.get(i).getHourYear());
			uct.setZhongydxHour(Double.valueOf(fmt.format(zhongydxBean.get(i).getHours())));
			uct.setZtbHour(Double.valueOf(fmt.format(ztbBean.get(i).getHours())));
			uct.setZhutbHour(Double.valueOf(fmt.format(zhutbBean.get(i).getHours())));
			uct.setJwpxHour(Double.valueOf(fmt.format(jwpxBean.get(i).getHours())));
			uct.setQitHour(Double.valueOf(fmt.format(qitBean.get(i).getHours())));
			uct.setZxHour(zxHourList.get(i).getZxHour());
			uct.setZxZsHour(zxHourList.get(i).getZxZsHour());
			uct.setHours(hours);
			uct.setUserId(Integer.valueOf(queryCommond.getSearchUserID()));
			list.add(uct);
		}
		if(PropertyUtil.objectNotEmpty(queryCommond.getSearchYear())){
			for(ListIterator<UserClassTypeHour> ite=list.listIterator();ite.hasNext();){
				uct=ite.next();
				if(uct.getHourYear().equals(queryCommond.getSearchYear().toString())){
					list.clear();
					list.add(uct);
					break;
				}
			}
		}else{
			uct=new UserClassTypeHour();
			uct.setHourYear("合计");
			uct.setZhongydxHour(Double.valueOf(fmt.format(zhongydxHours)));
			uct.setZtbHour(Double.valueOf(fmt.format(ztbHours)));
			uct.setZhutbHour(Double.valueOf(fmt.format(zhutbHours)));
			uct.setJwpxHour(Double.valueOf(fmt.format(jwpxHours)));
			uct.setQitHour(Double.valueOf(fmt.format(qitHours)));
			uct.setZxHour(Double.valueOf(fmt.format(zxHours)));
			uct.setZxZsHour(Double.valueOf(fmt.format(zxZsHours)));
			uct.setHours(Double.valueOf(fmt.format(totalHours)));
			list.add(uct);
		}
		return list;
	}
	
	/**
	 * 我的参训情况
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return String
	 * @throws Exception
	 */
	@RequestMapping(value = "/myClassTrainingList")
	public String myClassTrainingList(@ModelAttribute("result") ClassUserQueryCommond queryCommond,
			HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute("resultState") ResultState resultState)throws Exception{
		resultState.setState(ResultState.RESULT_STATE_FAIL);//默认状态为失败
		User user=(User) request.getSession().getAttribute(SessionConstant.USER_INFO);
		if(PropertyUtil.objectNotEmpty(user)){
			queryCommond.setSearchUserID(user.getUserId());
			List<QueryClassUserBean> beans = classUserService.myClassTrainingList(queryCommond);
			queryCommond.setResultList(beans);
			resultState.setMessage("查询成功");
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		}else{
			resultState.setMessage("缺少参数，请联系管理员！");
		}
		return "";
	}
	
	/**
	 * 学员统计（管理员用）
	 * @author RongSL
	 * 2017年12月19日
	 * */
	@RequestMapping(value = "/findUserStatisticsByAdmin")
	public String findUserStatisticsByAdmin(@ModelAttribute("result") ClassUserQueryCommond queryCommond,
			HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);//默认状态为失败
		Department department = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		if(PropertyUtil.objectNotEmpty(queryCommond.getSearchDepId())){
			department=this.classUserDao.find(Department.class, queryCommond.getSearchDepId());
		}else if(!PropertyUtil.objectNotEmpty(department)){
			resultState.setMessage("缺少参数，请联系管理员！");
			return "";
		}
		Calendar c=Calendar.getInstance();
		queryCommond.setSearchTreePath(department.getTreepath());
		//判断查询条件是否包含开班时间
		if(PropertyUtil.objectNotEmpty(queryCommond.getSearchBeginDate())||PropertyUtil.objectNotEmpty(queryCommond.getSearchEndDate())){
			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
			//判断查询开班时间，如果为空则默认为五年前
			if(PropertyUtil.objectNotEmpty(queryCommond.getSearchBeginDate())){
				c.setTime(format.parse(queryCommond.getSearchBeginDate()));
				queryCommond.setSearchYearStart(c.get(Calendar.YEAR));
			}else{
				c.setTime(new Date());
				queryCommond.setSearchYearStart(c.get(Calendar.YEAR)-5);
			}
			//判断查询结班时间，如果为空则默认当前年
			if(PropertyUtil.objectNotEmpty(queryCommond.getSearchEndDate())){
				c.setTime(format.parse(queryCommond.getSearchEndDate()));
				queryCommond.setSearchYearEnd(c.get(Calendar.YEAR));
			}else{
				c.setTime(new Date());
				queryCommond.setSearchYearEnd(c.get(Calendar.YEAR));
			}
		}else{
			if(!PropertyUtil.objectNotEmpty(queryCommond.getSearchYear())){
				c.setTime(new Date());
				queryCommond.setSearchYear(c.get(Calendar.YEAR));
			}
		}
		List<QueryClassUserBean> beans=null;
		try{
			beans = classUserService.findUserClassTypeHourList(queryCommond);
		}catch(Exception e){
			e.printStackTrace();
			resultState.setMessage("查询条件不正确，请检查后重新查询！");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
			return "";
		}
		//当存在查询班级时间的条件时，从实时数据中查询班级学时进行填充，没有数据则填充为0.0
		boolean flag;
		if(PropertyUtil.objectNotEmpty(queryCommond.getSearchBeginDate())||PropertyUtil.objectNotEmpty(queryCommond.getSearchEndDate())){
			for(QueryClassUserBean q:beans){
				flag=false;
				queryCommond.setSearchUserID(q.getUserId());
				//查询该学员所有年度的培训班学时汇总
				List<QueryClassUserBean> l=classUserService.findYearHourListByYear(queryCommond);
				if(!l.isEmpty()){
					for(QueryClassUserBean qcu:l){
						if(qcu.getHourYear().equals(q.getHourYear())){
							q.setZhongydxHour(qcu.getZhongydxHour());
							q.setZhutbHour(qcu.getZhutbHour());
							q.setZtbHour(qcu.getZtbHour());
							q.setJwpxHour(qcu.getJwpxHour());
							q.setQitHour(qcu.getQitHour());
							flag=true;
						}
					}
					if(!flag){
						q.setZhongydxHour(0.0);
						q.setZhutbHour(0.0);
						q.setZtbHour(0.0);
						q.setJwpxHour(0.0);
						q.setQitHour(0.0);
					}
				}
			}
		}
		if(!beans.isEmpty()&&PropertyUtil.objectNotEmpty(queryCommond.getSearchYear())&&queryCommond.getSearchYear().intValue()==-1){
			QueryClassUserBean ucu;
			Double ztbHours = 0.0;
			Double zhutbHours = 0.0;
			Double zhongydxHours = 0.0;
			Double jwpxHours = 0.0;
			Double qitHours = 0.0;
			Double totalHours = 0.0;
			Double zxHours = 0.0;
			Double zxZsHours = 0.0;
			for(QueryClassUserBean qcu:beans){
				ztbHours += qcu.getZtbHour();
				zhutbHours += qcu.getZhutbHour();
				zhongydxHours += qcu.getZhongydxHour();
				jwpxHours += qcu.getJwpxHour();
				qitHours += qcu.getQitHour();
				zxHours += qcu.getZxHour();
				zxZsHours += qcu.getZxZsHour();
				totalHours +=  qcu.getZtbHour()+qcu.getZhutbHour()+qcu.getZhongydxHour()+qcu.getJwpxHour()+qcu.getQitHour()+qcu.getZxZsHour();
			}
			ucu=new QueryClassUserBean();
			ucu.setHourYear("合计");
			ucu.setZtbHour(ztbHours);
			ucu.setZhutbHour(zhutbHours);
			ucu.setZhongydxHour(zhongydxHours);
			ucu.setJwpxHour(jwpxHours);
			ucu.setQitHour(qitHours);
			ucu.setZxHour(zxHours);
			ucu.setZxZsHour(zxZsHours);
			ucu.setHours(totalHours);
			ucu.setLoginID("-");
			ucu.setUserName("-");
			ucu.setDepName("-");
			ucu.setSexCode("-");
			ucu.setDutyLevelName("-");
			ucu.setUserId(beans.get(0).getUserId());
			beans.add(ucu);
		}
		
		queryCommond.setResultList(beans);
		resultState.setMessage("查询成功");
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return "";
	}
	
	/**
	 * 自动更新学员学时统计情况
	 * @author RongSL
	 * 2017年12月20日
	 * */
	@RequestMapping(value = "/QuartzUpdateUserHourStatistics")
	public void QuartzUpdateUserHourStatistics(){
		Long startDate=System.currentTimeMillis();
		ClassUserQueryCommond queryCommond=new ClassUserQueryCommond();
		queryCommond.setLimit(-1);
		queryCommond.setSearchTreePath(DeptConstants.XCH_DEPT_PATH);
		try {
			List<QueryClassUserBean> beans=this.classUserService.findUserStatisticsByAdmin(queryCommond);
			//初始化查询时间
			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Calendar cal = Calendar.getInstance();
			cal.setTime(new Date());
			//查询开始时间，默认当前时间前5年
			queryCommond.setSearchBeginDate(cal.get(Calendar.YEAR)-5+"-01-01 00:00:00");
			//查询截止时间，当前时间
			queryCommond.setSearchEndDate(format.format(new Date()));
			UserClassTypeHour u;
			for(QueryClassUserBean qcub:beans){
				queryCommond.setSearchUserID(qcub.getUserId());
				queryCommond.setDutyLevelId(qcub.getDutyLevelCode());
				//查询学员学时获得情况
				List<UserClassTypeHour> ucyhs=buildUserHourStatistics(queryCommond);
				for(UserClassTypeHour ucth:ucyhs){
					if(!StringUtils.isNumeric(ucth.getHourYear())){
						continue;
					}
					queryCommond.setYear(Integer.valueOf(ucth.getHourYear()));
					u=this.classUserDao.findUserClassTypeHour(queryCommond);
					if(PropertyUtil.objectNotEmpty(u)){
						org.springframework.beans.BeanUtils.copyProperties(ucth, u,new String[]{"ID","createDate"});
						this.classUserDao.update(u);
					}else{
						u=new UserClassTypeHour();
						BeanUtils.copyProperties(ucth, u);
						this.classUserDao.save(u);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("更新学员学时统计数据出错!");
		}
		System.out.println("整体用时:"+(System.currentTimeMillis()-startDate)/1000/60+"分"+(System.currentTimeMillis()-startDate)/1000%60+"秒");
	}
	
	/**
	 * 导出Excel 当前单位下人员学时详情列表
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @throws Exception
	 * @author RongSL
	 * 2017年12月22日
	 */
	@RequestMapping(value = "/exportUnqualifiedUserListExcel")
	public void exportUnqualifiedUserListExcel(Model model, HttpServletRequest request, ClassUserQueryCommond queryCommond, HttpServletResponse response) throws Exception {
		Department department = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		if(PropertyUtil.objectNotEmpty(queryCommond.getSearchDepId())&&!queryCommond.getSearchDepId().equals("undefined")){
			department=this.classUserDao.find(Department.class, queryCommond.getSearchDepId());
		}else if(!PropertyUtil.objectNotEmpty(department)){
			response.setCharacterEncoding("GB2312");
			PrintWriter pw = response.getWriter();
			pw.write("<script>alert('登陆超时，请重新登录后再次操作！);window.opener='';window.open('', '_self', '');window.close();</script>");
			pw.close();
		}
		queryCommond.setSearchTreePath(department.getTreepath());
		if(!PropertyUtil.objectNotEmpty(queryCommond.getSearchYear())){
			Calendar c=Calendar.getInstance();
			c.setTime(new Date());
			queryCommond.setSearchYear(c.get(Calendar.YEAR));
		}
		//不分页
		queryCommond.setLimit(-1);
		List<QueryClassUserBean> beans = classUserService.findUserClassTypeHourList(queryCommond);
		if(beans.isEmpty()){
			response.setCharacterEncoding("GB2312");
			PrintWriter pw = response.getWriter();
			pw.write("<script>alert('暂无数据');window.opener='';window.open('', '_self', '');window.close();</script>");
			pw.close();
		}else{
			List<ExportUserBean> userList = new ArrayList<ExportUserBean>();
			for (QueryClassUserBean qcub : beans) {
				ExportUserBean eub = new ExportUserBean();
				BeanUtils.copyProperties(qcub, eub);
				userList.add(eub);
			}
			// 设置并导出人员列表
			UserExport userExport = new UserExport();
			userExport.setExportUserBeanList(userList);
			UserSheet userSheet = new UserSheet();
			userSheet.setExportObject(userExport);
			userSheet.setExprotFormatName("unqualifiedUserListExportConfig");
			userSheet.setSheetName("学员列表");
			
			Sheet[] sheetArray = new Sheet[] { userSheet };// 导出Excel的Sheet集合
			ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
			String title = "学员列表";
			response.setContentType("application/msexcel;charset=ISO8859-1");
			response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
			OutputStream out = response.getOutputStream();
			excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
		}
	}
	
	/**
	 * 人员班级统计
	 * @author RongSL
	 * 2018年3月7日
	 * */
	@RequestMapping("/findStatisticsUserByClass")
	public String findStatisticsUserByClass(ClassUserQueryCommond queryCommond,HttpServletRequest request, HttpServletResponse response,@ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);//默认状态为失败
		try{
			List<QueryClassUserBean> list=this.classUserService.findStatisticsUserByClass(queryCommond);
			queryCommond.setResultList(list);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		}catch(Exception e){
			e.printStackTrace();
			resultState.setMessage("缺少参数，请联系管理员！");
		}
		return "";
	}
	
	/**
	 * 人员班级统计
	 * @author RongSL
	 * 2018年3月14日
	 * */
	@RequestMapping("/exportStatisticsUserByClassExcel")
	public void exportStatisticsUserByClassExcel(ClassUserQueryCommond queryCommond,HttpServletRequest request, HttpServletResponse response,@ModelAttribute("resultState") ResultState resultState) throws Exception {
		response.setCharacterEncoding("GB2312");
		try{
			queryCommond.setLimit(-1);
			List<QueryClassUserBean> list=this.classUserService.findStatisticsUserByClass(queryCommond);
			//不分页
			if(list.isEmpty()){
				PrintWriter pw = response.getWriter();
				pw.write("<script>alert('暂无数据');window.opener='';window.open('', '_self', '');window.close();</script>");
				pw.close();
			}else{
				List<ExportUserBean> userList = new ArrayList<ExportUserBean>();
				for (QueryClassUserBean qcub : list) {
					ExportUserBean eub = new ExportUserBean();
					BeanUtils.copyProperties(qcub, eub);
					userList.add(eub);
				}
				// 设置并导出人员列表
				UserExport userExport = new UserExport();
				userExport.setExportUserBeanList(userList);
				UserSheet userSheet = new UserSheet();
				userSheet.setExportObject(userExport);
				userSheet.setExprotFormatName("statisticsUserListExportConfig");
				userSheet.setSheetName("单位学习情况统计");
				
				Sheet[] sheetArray = new Sheet[] { userSheet };// 导出Excel的Sheet集合
				ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
				String title = "学员列表";
				response.setContentType("application/msexcel;charset=ISO8859-1");
				response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
				OutputStream out = response.getOutputStream();
				excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
